Dequeue jQuery Migrate

How-To Dequeue jQuery Migrate

How-To Dequeue jQuery Migrate

Ever since WordPress 4.5 jQuery Migrate has been included in the core. This can be a useful addition for those that are using themes or plugins that rely on older jQuery code. You’ll notice that by having jQuery Migrate installed on your site aka WordPress 4.5+ the following will output in your developer console:

JQMIGRATE: Migrate is installed, version 1.4.1

If you don’t use any old pre-1.9 jQuery in your theme you can safely disable the jQuery Migrate with the following addition to the bottom of your theme’s functions.php file:

add_action( 'wp_default_scripts', function( $scripts ) {
if ( ! empty( $scripts->registered['jquery'] ) ) {
$scripts->registered['jquery']->deps = array_diff( $scripts->registered['jquery']->deps, array( 'jquery-migrate' ) );
}
} );

Adding the above to your functions.php file will dequeue jQuery Migrate and mute the message above from displaying in your developer console. I hope you found this post useful, feel free to leave your comments, suggestions or feedback below, Thanks!

DIGITAL PCI © 2018