ClassicPress PetitionsClassicPress Petitions
This is a read-only archive. Post or comment on the live version of this page on our forums.

jQuery to vanilla JS

August 1, 2019 · 09:50 · Lodder

I'm going to propose that the core of ClassicPress be rewritten using vanilla Javascript.

Please note that I'm NOT suggesting dropping jQuery. The file will still reside in the product to allow plugin developer to use it if they wish.

The benefits of moving to vanilla Javascript:

  1. Massive runtime performance increase
  2. Less http requests
  3. No B/C break when updating jQuery

If this is done correctly, there will be no B/C breaks and all plugins that depend on any core Javascript will still work in exactly the same manner.

+25 more
Remzi Cavdar

Also I would suggest to defer them or put all scripts in the footer. In this way we could get an other performance boost.


@Remzi, there are better ways than deferring them. Properly lazy loading them using a small inline JS snippet is the best approach, but one step at a time ;)

Laurence Bahiirwa

Having this in mind, what would the minimum browser support look like especially for the admin side?


@Laurence it can be the same as it currently is (IE11+) or if the owners decide to drop IE support, even better

James Nylen

1 and 2 are definitely good reasons to do this.

I am not so sure about 3. Most of the issues that occur when upgrading jQuery are due to plugin incompatibility. Another issue that also needs to be checked for is plugins that assume jQuery is available and use it without declaring it as a dependency in their scripts.

See also related discussion at


@James, by point 3, I'm referring to updating jQuery from 2.x to 3.x, which I believe Wordpress having been doing for the last 3 years. By not relying on jQuery in the core, you won't have 3 years old tickets like that.

ClassicPress uses semantic versioning, do any dependencies that are updated and would introduce B/C breaks for plugins should results in ClassicPress releasing a new major version.

Tim Kaye

I think this is an interesting proposal and, if someone is willing to take it on, by all means go for it. But I think it's almost certainly misguided.

JavaScript was dying a death until jQuery came along. Now it has renewed interest because of frameworks like React, Angular, Vue, Ember, etc, not to mention Bootstrap. There must be a reason why significant projects always seem to rely on frameworks and libraries rather than vanilla JavaScript.


@Tim - jQuery was originally created to build a so called bridge between each browser and their inconsistencies, in addition to being able to do things with less code. Now that we have evergreen browsers (other than IE11), writing vanilla JS is just as easy as the methods that come with jQuery and we no longer have those inconsistencies. jQuery is dying at an extremely fast rate. You only have to look at the trends on Google since 2013 :)
jQuery was amazing back in its peak time, but there are now better things out there. Like any framework, B/C breaks are a major problem, so my suggestion of using native JS will alleviate the pain of updating in the future.

This will be an extremely big task, so many it would be better to wait until ClassicPress has a little more interest and more developers.

Tim Kaye

@Lodder: Yes, I am aware of jQuery's history. But I treat reports of its impending demise with more than a pinch of salt. People are still producing jQuery plugins at a rate of knots, for example.

And jQuery offers many other benefits besides normalization, which is why it's still used by things like Bootstrap. If you want to do something complex, for which there's already a jQuery function, why bother with having to write all that verbose vanilla JavaScript from scratch? Even the performance issue isn't as clear-cut as is often paraded. After first page load, jQuery is cached by the browser.

But I expressly said that anyone who wants to take this on should go for it. I'm not arguing against someone trying. I am just skeptical about whether it's worth all the effort that will be entailed.

Bryan Ollendyke

It's not going anywhere but I'd recommend trying to replace pieces of core one project at a time with VanillaJS equivalent ONLY if you're trying to attract outside influences. Everything I do is web components now (mostly vanilla) and it took better part of a year to eliminate all our jQuery in our platform (which sits on top of Drupal).

If the point is performance, ok but it's a lot of effort for small gain. If the point is a future where more JS advanced devs arrive on scene, then I think this is a bigger signal to that crowd then existing migrating parties as to the wins of ClassicPress.