How to remove jQuery Migrate from WordPress?

When it comes to website optimization, even an additional request matters a lot, especially when users are accessing it from the mobile platform. jQuery is the biggest javascript file that is loaded alongside your theme. If your theme uses a mobile menu or similar jQuery-based functions, you will require jQuery anyway, but jQuery Migrate is just an additional file that loads with jQuery. Most of the time it is not required unless we are using decade-old functions. So in this tutorial, I am going to explain how to remove jQuery Migrate from WordPress.

jQuery Migrate

Make a backup of everything before you start any editing.

1. Open the “functions.php” file and add the following code.

Note: If you are not familiar with PHP then get some help, because you may break anything.

Locate functions.php file and add the following code at the end of the page.

// Remove jQuery Migrate
function atulhost_optimize_scripts() {
	wp_deregister_script('jquery');
	wp_deregister_script('jquery-migrate');
	wp_register_script('jquery',includes_url('/js/jquery/jquery.js'),false,null);
	wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'atulhost_optimize_scripts');

2. Save the “functions.php” file and clear the cache.

Simply save the file and delete all the cache to see it in action. Now check the homepage’s page source and look for jQuery Migrate script, it should be removed.

This is how we can remove jQuery Migrate script from WordPress.

Published by AtulHost

Creator of AtulHost. An ardent Linux user. Comes from a business management background. Loves to do research on modern business insights and technological solutions.

Leave a reply

Required fields are asterisked and email address will not be shared.