'remove_jquery_migrate', 'title' => 'Drop legacy jQuery polyfill', 'desc' => 'Stop loading jquery-migrate.js on the front end', 'icon' => 'code', 'risk' => 'advanced', 'level' => 'advanced', 'audience' => 'developer', 'priority' => 9, 'benefit' => 'jQuery Migrate (about 13 KB, 5 KB compressed) keeps older jQuery code working. If your theme and plugins do not rely on that older code, it is not needed on the front end.', 'help' => 'Removes jquery-migrate.min.js from the front end; the admin keeps it. jQuery itself still loads. Some older themes and plugins still use jQuery features that need it, so if something on the site stops working, turn this off.', 'before' => 'jquery-migrate.min.js loaded on the front end with jQuery', 'after' => 'Removed on the front end. jQuery itself still loads.', 'detect' => function () { // Check if any active plugin or theme explicitly requires jQuery Migrate // Simple heuristic: if WP is 6.0+ and no ancient plugins, likely safe. global $wp_version; $safe = version_compare( $wp_version, '6.0', '>=' ); return array( 'detected' => true, 'message' => $safe ? 'Modern WP version — likely safe to remove' : 'Older WP — some plugins may need jQuery Migrate', 'safe' => $safe, 'savings' => '~5KB gzipped JS', ); }, 'callback' => function () { add_action( 'wp_default_scripts', function ( $scripts ) { if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) { $scripts->registered['jquery']->deps = array_diff( $scripts->registered['jquery']->deps, array( 'jquery-migrate' ) ); } } ); }, );