Disabling jQuery Migrate for Improved Performance

Hamid Rezazadeh |11 May, 2024 | WordPress optimization, jQuery Migrate deactivation, Improved website performance, WordPress speed enhancement, jQuery Migrate functionality, Removing jQuery Migrate, Retroactive compatibility solution, Deprecated jQuery features, Legacy code maintenance, Transition to newer jQuery versions | wordpress | 0 Comments | View Counts (620) |Return|
0 ( 0 reviews)

Disabling jQuery Migrate in WordPress

The jQuery Migrate script is a valuable component of WordPress, facilitating the transition from older jQuery versions to newer ones. In this guide, we delve into the process of deactivating jQuery Migrate within WordPress, shedding light on its functionality and the rationale behind its removal.

Let’s get started!

Understanding jQuery Migrate

jQuery Migrate stands as a JavaScript library, acting as a retroactive compatibility solution to maintain the functionality of jQuery code developed for versions predating 1.9.

Among its capabilities lies the restoration of removed APIs. Moreover, the development iteration of the Migrate script is adept at issuing warnings for absent or deprecated APIs.

How Does it Work? Unraveling its Mechanism

jQuery Migrate performs a crucial role by identifying deprecated features and restoring them, thereby facilitating seamless execution of older code on the latest jQuery iteration.

This empowers developers to transition to newer jQuery versions, assured that legacy code will seamlessly function.

To disable jQuery Migrate, add the following code to the functions file of your theme.

 //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' );

About the Author


Making the email field optional in WooCommerce

Making the email field optional in WooCommerce

If you use WordPress content management system to manage your site and WooCommerce to sell your prod...

Read More >

Post a Comment