When building WordPress plugins for myself or others, several of the things I take into account – as we all should – is the level of maintainability, scalability, and support for the plugin as WordPress continues to move forward.

Specifically, I’m talking about client-side development (or, more simply, JavaScript).

As the support for ES6 continues to rise, jQuery continues to move forward with development, and the desire to use new APIs to build out our solutions, I believe it’s worth asking the question:

Do we really need to stick with jQuery?

jQuery Versus ES6 in WordPress

Of course, for anyone who writes any level of JavaScript, you know that this particular question doesn’t have a yes or a no answer. It’s more of a “why not both?” right?

jQuery Versus ES6 in WordPress: Why Not Both?

First, I think it’s important to recognize that at one point in time, jQuery really helped us manage browser inconsistencies but that’s not so much the case anymore. This is primarily because most of the modern browsers support many of the common APIs.

jQuery Versus ES6 in WordPress: What Can Web Do Today?

Secondly, even though the browser inconsistency thing isn’t as much as problem as it once was, jQuery still makes it easy to crawl, manipulate, and, ahem, query the DOM in an easy fashion (especially if you conceptualize the DOM as the data structure that it is).

jQuery Versus ES6 in WordPress: You Might Not Need jQuery

Third, because jQuery is JavaScript, it’s not a matter of “do we use jQuery or not.” I mean, you can use it and the features offered by ES6 as it continues to progress. Thus, if you’re someone who’s experienced in both but not sure which to use, it’s completely fine to mix them.

It’s all the same programming language. jQuery just offers an API that ES6 does not and if you need or want that convenience, then go for it.

One More Thing

I think there’s still a discussion around how to organize jQuery-based JavaScript. That’s one thing that can turn into spaghetti code quickly if not managed properly. But that’s a content for another post that I hope to write soon.

For now, just remember that the idea of “should I use jQuery because it’s bundled with WordPress or use ES6 because it’s the most modern variant of the language” is not binary.

It’s more of “do I want or need to use ES6 with jQuery?” or perhaps it’s “do I want or need to use jQuery along with ES6?”

Ultimately, I don’t find it worth stressing about it. Instead, I find it worth determining the best course of action for the problem at hand and working from there.