Wp enqueue deprecation PartII

Similar to closed thread “Deprecated: Function wp_enqueue_script was called with an argument that is deprecated since version CP-2.2.0! The enqueued script jquery-ui-core has been deprecated.”

Context

For this “error” it is basically saying "why enqueue something that is not going to be used.” So this is simple to understand that CP does not use/depend on jQuery.

Is there a work around to allow the use of jQuery for plugins that have its dependencies? Should we add wp_enqueue_script into a functions file of theme and use a conditional if([plugin]_class_exists() to enqueue. Or is there any snippets that the community might share when actually using jQuery?

you have to use vanilla JS.

My process is passing all the files to an AI and detect where that code that uses the deprecated script is used, and I convert the code from the deprecated library in a vanilla JS snippet of code. That way the plugin or theme works the same without having to mess up with libraries.

2 Likes

If I’m not mistaken there’s a function in CP that contains a list of deprecated scripts. Maybe it’s possible to hook into that and revert that?

Personally I’m ok with the goal to make CP core jQuery free, but disagree with “forcing” theme and plugin devs to do the same. Many themes and plugins from WP will not work anymore if those scripts are removed. I still need plugins from WP, guess most of us do.

I think having plugins or themes using deprecated scripts defeats the purpose of having a clean core. The goal is to encourage Devs to develop CP specific software that is free of deprecated scripts, in the long run CP should stand on its own since WP will continue to diverge

1 Like

Pretty certain there are many CP users that don’t care about jQuery being removed. They use CP because of the Classic Editor and their dislike of the block editor and FSE.

1 Like

Good responses. So in general we would need to encourage plugin developers to write all vanilla instead of jQuery. Sounds reasonable.

2 Likes

@Guido07111975 CP was about cleaning the JS dependencies in favor of Vanilla JS from the very start when Scott Bowler and others forked WP in late 2018. The very first RC of V1.0 Aurora was all about that in fact.
Obviously this means that CP has always made clear that to develop for CP one has to forego JQuery among others, and that while it was true that some plugins and themes would continue to work, that was not a guarantee because CP’s aim was to build its very own ecosystem.
CP community always was clear about that. If you really need JQuery you can totally use WP (it’s not one OR the other IMHO - as I said in other places it’s about selecting the right CMS for the job).
One thing I am doing, I am slowly buiding my suite of tools (plugins and themes) to work with CP leveraging what it has to offer, instead of focusing on what it has not. I think for me this works better than trying to force WP stuff to work into it.

4 Likes

So to remove the dep’ warning I will need to update the UI jQuery in my theme ClassicSixteen/js/functions.js at dbfffaf1b1ba93e11359396f457395466d414341 · tradesouthwest/ClassicSixteen · GitHub Thanks for the input. Will create a new release soon.

2 Likes

You need to distinguish between jQuery and jQuery UI. Elisabetta is correct about everything she says, but core is not deprecating jQuery at the moment. And it won’t be doing so for some time yet because (while we have replaced a lot of jQuery in core with vanilla JS) there is still a lot of jQuery in core.

However, jQuery UI has been completely removed from core, except in one place (and I’m working on that one at the moment). So jQuery UI is deprecated and will probably be removed from CP in version 3.

The full list of deprecated scripts is at Deprecated Scripts | ClassicPress

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.