Remove jquery-migrate

I don’t see instructions for this in the forum. It seems like a pretty safe way to save on an unnecessary request, and to gain a small boost on PageSpeed.

Be careful if you use any plugins that might use outdated jquery.

Add to setup.php or wherever you prefer:

/**
 * Remove JQuery migrate
 * https://joewp.com/en/remove-jquery-migrate/
 */
add_action('wp_default_scripts', function ($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'
            ));
        }
    }
});

Something for Soil perhaps??

2 Likes

This topic was automatically closed after 42 days. New replies are no longer allowed.