Dotlayer
  • News
  • Startups
  • Tutorials
  • SEO
  • Marketing
  • Interviews
No Result
View All Result
Dotlayer
  • News
  • Startups
  • Tutorials
  • SEO
  • Marketing
  • Interviews
No Result
View All Result
Dotlayer
No Result
View All Result

What is Migrate.js – Why and How to Remove jQuery Migrate from WordPress

August 26, 2018
in Tutorials
0 0
Share on FacebookShare on Twitter

jQuery Migrate is a javascript library that allows you to preserve the compatibility of your jQuery code developed for versions of jQuery older than 1.9. It basically restores deprecated features and behaviours so that older code will still run properly on the current jQuery version and later. Starting with WordPress 3.6, jQuery Migrate is automatically included on all pages.

Most websites that use up-to-date themes and plugins don’t require jQuery Migrate on the frontend, and thus the script can be safely removed. By removing it, the browser will have one less JavaScript file to download and execute. As a result, your site will load faster!

If you keep your jQuery code up-to-date and are sure that none of your plugins is incompatible with jQuery 1.9 or jQuery 1.10.2 (the new default version in WordPress 3.6), you can just remove the script from on the front-end.

Most up-to-date frontend code and plugins don’t require jquery-migrate.min.js. More often than not, keeping this simply adds unnecessary load to your site. You can see this running if you launch Chrome Devtools console.

Three reasons why it’s a good idea to remove jquery migrate

  • There is no reason to waste an extra HTTP call to serve an extra JS file.
  • It’s better to keep your code, themes and plugins updated than it is to patch in support with an extra file.
  • If you are running plugins that use older jQuery code, it’s probably better to update them or switch to an alternative that is kept updated.

How to remove jQuery migrate from WordPress?

Removing jQuery migrate from WordPress is quite easy. You just need to add following lines of code to your theme’s function.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 easy way to disable it by using the plugin named Remove jQuery Migrate Safely. If you are unsure if your website still requires jQuery Migrate, you can add the following line to your wp-config.php and watch the console as you browse your site for any logs.

define('SCRIPT_DEBUG', true);

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.

ShareTweetPin
Previous Post

Hilarious and Candid Interview with Founder and CEO of “The Cut Buddy”, A Men’s Grooming Startup, Joshua Esnard

Next Post

Five Tips to Writing a Blog for Beginners

Next Post

Five Tips to Writing a Blog for Beginners

You might also like

Calendarific Unveils New Pricing Plans

Calendarific Unveils New Pricing Plans

July 27, 2023
CurrencyBeacon vs. Currency Freaks, Fixer.io, and OpenExchangeRates: Which API is Best?

CurrencyBeacon vs. Currency Freaks, Fixer.io, and OpenExchangeRates: Which API is Best?

June 17, 2023
Mint Linux vs Ubuntu: Which is Right For You?

Mint Linux vs Ubuntu: Which is Right For You?

March 12, 2022
Net Neutrality: What is it and Why Should You Care?

Net Neutrality: What is it and Why Should You Care?

March 12, 2022
Solid State Drives – Why You Should Buy One Today

Solid State Drives – Why You Should Buy One Today

March 12, 2022

Machine Learning Algorithms Every Beginner Should Know

January 25, 2022
  • Terms of Service
  • Privacy Policy
  • Careers

© 2021 Dotlayer.com

No Result
View All Result
  • About Us
  • Advertise
  • Blog
  • Careers
  • Contact
  • Contact Us
  • Get Featured
  • Home Layout 1
  • Home Layout 2
  • Home Layout 3
  • Privacy Policy
  • Security
  • Services
  • Subscribe To Dotlayer
  • Terms of Service
  • Write For Us

© 2021 Dotlayer.com

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In