Updating jQuery UI on WordPress to the latest version (1.12.1)

Working as a freelancer gives us access to a broad range of problems and issues. Last week I had to find out how to update jQuery UI on WordPress to the latest version.

One on my regular clients had issues with jQuery UI version and security compliance. WordPress ships with jQuery UI version 1.11.4 which, according to this link https://github.com/jquery/api.jqueryui.com/issues/281, has a security issue and the client’s website could not pass security compliance.

As always I googled and tried to find a solution, code snippet or a plugin. I found a couple of excellent plugins that can update the jQuery version on WordPress(link, link) but I could not find a solution for updating jQuery UI to the latest version(1.12.1).

I decided to do it manually but a new problem arose. jQuery UI in version 1.12 is packed into one file, while older versions have separate files for widgets and effects. If I replace all files with just one it would probably break WordPress functionality as it has separate handlers for every jQuery UI file.

Hopefully, I found this https://github.com/jquery/jquery-ui/tree/1.12.1, downloaded separate files, minified then, checked all dependencies and successfully replaced jQuery UI 1.11.4 with the latest version, 1.12.1.

This can be done through functions.php in your theme and you can download files HERE. You need to copy files and folder to your child theme and include the jqueryui_replace.php file in your functions.php file.

The other way is a small plugin that I made for updating jQuery, jQuery Migrate and jQuery UI to the latest versions. Replacement is made on the fly and if there is any problem just deactivate the plugin. You can download the plugin HERE.

The plugin is installed on this website too and you can check several jQuery UI elements working on THIS page.

Please note that you should fully test your website in staging before applying this code or plugin in production. I am not responsible for any damage these modifications may cause. In case of any problem you just need to deactivate the plugin or remove the including line from the functions.php file.

Leave a Reply

Your email address will not be published. Required fields are marked *