We can remove jquery.migrate.js for frontend user’s easily.
copy and paste below code in your child theme functions.php or your custom plugin. That code will remove jquery.migrate.js for frontend users and it will work for admin panel.
How to Safely Remove jquery.migrate.js in WordPress for Improved Performance
If you’re looking to optimize your WordPress site’s performance, removing unnecessary scripts like jquery.migrate.js can be a great step. This script is often included by default but may not be necessary for many modern themes and plugins. Here’s a detailed guide on how to safely remove jquery.migrate.js from your WordPress site.
Why Remove jquery.migrate.js?
- Performance Improvement: Reducing the number of scripts loaded can improve your site’s load time.
- Security: Fewer scripts mean fewer potential vulnerabilities.
- Modern Standards: Many themes and plugins no longer rely on jquery.migrate.js, making it redundant.
Steps to Remove jquery.migrate.js
1. Backup Your Site
Before making any changes, it’s crucial to back up your WordPress site. This ensures that you can restore your site in case anything goes wrong.
2. Update Your Theme and Plugins
Ensure that your theme and all plugins are up to date. Developers often update their code to remove dependencies on jquery.migrate.js, so this step might solve the issue without further action.
3. Add Code to Your Functions.php File
To remove jquery.migrate.js, you’ll need to add a small code snippet to your theme’s functions.php
file. Here’s how:
- Access your WordPress dashboard and navigate to
Appearance > Theme Editor
. - Select your theme from the dropdown menu on the right.
- Open the functions.php file for editing.
- Add the following code snippet at the end of the file:
function remove_jquery_migrate( $scripts ) {
if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) {
$script = $scripts->registered['jquery'];
if ( $script->deps ) {
$script->deps = array_diff( $script->deps, array( 'jquery-migrate' ) );
}
}
}
add_action( 'wp_default_scripts', 'remove_jquery_migrate' );
- Save the changes.
4. Test Your Site
After saving the changes, it’s essential to test your site thoroughly. Check both the front-end and back-end to ensure that everything is working correctly. Pay special attention to any custom JavaScript functionality that might rely on jquery.migrate.js.
5. Monitor for Issues
Keep an eye on your site’s performance and error logs. If you encounter any issues, you may need to re-enable jquery.migrate.js or find alternative solutions for specific functionalities that depended on it.
Conclusion
Removing jquery.migrate.js from your WordPress site can lead to better performance and security. By following these steps, you can safely remove this script and ensure your site continues to run smoothly. Always remember to back up your site and test thoroughly after making changes.
Additional Tips
- Regular Maintenance: Regularly update your themes and plugins to keep your site optimized.
- Use a Child Theme: If you’re editing core theme files, consider using a child theme to avoid losing changes during updates.
- Seek Professional Help: If you’re not comfortable editing code, consider hiring a professional developer.
By optimizing your WordPress site and removing unnecessary scripts, you can provide a better experience for your visitors and improve your site’s overall performance.
1 thought on “How to remove jquery.migrate.js in wordpress?”