InfoPhilicHow toHow to remove jQuery Migrate in WordPress?

How to remove jQuery Migrate in WordPress?

jQuery Migrate dramatically simplifies the process of moving older jQuery code to a higher jQuery version by identifying deprecated features. It then restores deprecated features and behaviors so that older code runs properly on the current jQuery version and later.

Most up-to-date frontend code and plugins don’t require jquery-migrate.min.js. In most cases, this adds unnecessary load to your site. You can see this running if you launch the Chrome Devtools console.

Other reasons to remove jQuery Migrate:

  • It’s better to keep your code, themes, and plugins updated than to patch them in support of an extra file. Keeping your site updated also prevents it from Security attacks.
  • If you are running plugins that use older jQuery code, it’s probably better to update them or switch to an alternative that keeps them updated.

How to remove jQuery migrate from WordPress?

Removing jQuery migrate from WordPress is relatively easy. You need to add the following lines of code to your theme’s functions.php file.

//Remove JQuery migrate
 
function remove_jquery_migrate( $scripts ) {
   if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) {
        $script = $scripts->registered['jquery'];
   if ( $script->deps ) { 
// Check whether the script has any dependencies

        $script->deps = array_diff( $script->deps, array( 'jquery-migrate' ) );
 }
 }
 }
add_action( 'wp_default_scripts', 'remove_jquery_migrate' );

Another straightforward way to disable it is by adding Remove jQuery Migrate plugins.

Remove jQuery Migrate:

This plugin removes the jQuery Migrate script from the front end of your site.

Go to Dashboard: Sign in to your WordPress site to open the dashboard.

Go to Plugins: You will see the Plugins menu on the left-hand side menu bar. Clicking it will expand more options; click Add New.

Search for Remove jQuery MigrateType Remove jQuery Migrate in the search bar, as shown in the picture.

Add new plugin to WordPress site

Click Install Now

Install Remove jQuery Migrate plugin
  1. Activate the plugin; that’s it. The plugin will do the rest of your work.

This is the most used plugin that most developers suggest. However, there are also other plugins available that you can prefer.

Conclusion:

As I mentioned above, jQuery migrate adds unnecessary load to your site. Thus, I recommend removing it from your website or blog.

Is this article helpful? Let me know in the comment section below.

Continue Your Learning Journey with These Resources
Continue to the category
Amit Malewar
Amit Malewarhttps://www.infophilic.com/
Amit Malewar has been the tutorial writer since 2013. His passion for helping people in all aspects of technology flow through the expert coverage he provides. In addition to writing for InfoPhilic, Amit loves to read and try new things.

Comment Policy: Your words are your own, so be nice and helpful if you can. Please, only use your real name and limit the amount of links submitted in your comment. We accept clean XHTML in comments, but don't overdo it please.

5 COMMENTS
    • Hi Giri,

      Yes, you can add the mentioned code in the Newspaper theme. jQuery Migrate script will be removed by default from WordPress 5.7 (Upcoming update).
      I hope you will find this helpful.

  1. Never mind! I’ve created this and it works 🙂
    function remove_jquery_migrate_in_admin() {
    global $wp_scripts;
    $wp_scripts->remove(‘jquery’); // Remove default (because of jQuery Migrate dependency).
    $wp_scripts->remove(‘jquery-migrate’); // Prevent jQuery Migrate from being enqueued.
    $wp_scripts->add(‘jquery’, false, array(‘jquery-core’), ‘1.2.1’); // Add jQuery without jQuery Migrate.
    }
    add_action(‘admin_enqueue_scripts’, ‘remove_jquery_migrate_in_admin’);

LEAVE A REPLY

Please enter your comment!
Please enter your name here

CloudWays 40% OFF

Upgrade your hosting today!

Coupon Code: INFOPHILIC

  • Lightning-Fast Loading Times 🚀
  • Improved SEO Rankings 📈
  • Enhanced User Experience