Skip to content

Remove unnecessary dependencies #5

@k1sul1

Description

@k1sul1

Writing an issue as promised. As WP is going towards React, jQuery is becoming obsolete, and there's not much use for it even in the front-end due to native browser APIs finally being consistent between browsers. Only reason to use jQuery nowadays is because a plugin depends on it. Or because this depends on it. While the filesize of jQuery is practically nothing (compare it to an image), JS is quite slow to parse and execute, especially in mobile browsers.

You can use fetch() as an alternative to $.ajax. It's present in all evergreen browsers. It does depend on Promises, but those too are present in all evergreen browsers.

Unfortunately Fetch spec was half-assed, and currently there's no practical way to get a progress status, or cancel the request. That makes #2 rather interesting. Obviously it will get better over time but right now there are some drawbacks.

Fortunately XHR isn't that hard to use if you decide that you need progress and cancellable requests. I made a simple helper a year back: https://gist.github.com/k1sul1/1e34a2c5eab0f7d903037c0e3e8605e1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions