How do I stop WordPress loading jQuery and jQuery-migrate?

user2227359 picture user2227359 · Aug 24, 2013 · Viewed 21k times · Source

WordPress is loading the following 2 files in wp_head():

<script type='text/javascript' src='http://example.com/wp-includes/js/jquery/jquery.js?ver=1.10.2'></script>
<script type='text/javascript' src='http://example.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script>

In an attempt to stop this from happening, I have tried deactivating all plugins and deregistering jQuery in functions.php, but nothing seems to get rid of it.

Any ideas how I can stop this?

I'm using Wordpress v3.6.

Answer

Omar Abdirahman picture Omar Abdirahman · Sep 22, 2014

You might want to use this in your functions.php

add_filter( 'wp_default_scripts', 'remove_jquery_migrate' );

function remove_jquery_migrate( &$scripts){
    if(!is_admin()){
        $scripts->remove( 'jquery');
        $scripts->add( 'jquery', false, array( 'jquery-core' ), '1.2.1' );
    }
}

1.2.1 = latest version of jquery-migrate

If you want to check whether your site requires jquery-migrate, open wp-config.php and this line of code: define('SCRIPT_DEBUG', true);. That way you can monitor any errors. Don't forget to remove this when you put your site live!

Hope that helps.