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.
Massive runtime performance increase
Less http requests
No B/C break when updating jQuery
Read-only archive: https://petitions.classicpress.net/posts/187/jquery-to-vanilla-js
Vote count: 31
Having this in mind, what would the minimum browser support look like especially for the admin side?
~ posted by Laurence Bahiirwa
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
Move from jQuery to vanilla JS · Issue #454 · ClassicPress/ClassicPress · GitHub.
~ posted by James Nylen
@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.
~ posted by Lodder
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.
~ posted by Tim Kaye
@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.
~ posted by Lodder
@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.
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.
~ posted by Tim Kaye
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.
~ posted by Bryan Ollendyke
This petition had 31 votes and an
active discussion on Github. Seems like a good idea but a monumental effort. CP still uses jQuery v1 and I see there’s an effort to backport v3 from WP. So is this still a viable option/petition?
If we would have the people who actually know JS, with the time needed, we probably could do this.
Personally, if I use any JS like/related language, then jQuery much much more than plain JS mainly because if I use, then because it is inside a jQuery UI instance.
But that is just because it is “there”. If there is a similar pendant for plain JS or else, I would use that.
However core is massively relying on jQuery. Like
massively. The entire Customizer, Media, every single bit of the user interface, its all jQuery, not plain JS
This is like writing a new CMS I believe. Good idea, but we need:
a considerable amount of time
If we have that, I think it probably would be a cool thing. But I don’t think we have any of those resources.
We barely manage to (copy) write a documentation or do simple enhancements that are pending in Git since quite a while.
Thus probably I would keep it open but not put on any “must do” list.
I think a better first step is to move CP from using jQuery v1 to v3. I have already done that on many of my own sites and I haven’t had any issues (using a variation on this basic code to host v3 locally):
wp_deregister_script( 'jquery' );
wp_enqueue_script( 'jquery', 'xxx/jquery-3.6.0.min.js', null, null, true);
@anon66243189 is working on backporting jQuery v3 right now, so that’s already in progress.