Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Stop loading jQuery Migrate

jQuery Migrate helps very old jQuery code run. Most sites don’t need it on the public pages; the admin keeps it.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Category Performance
  • Tested with WordPress 7.1
PHP
<?php

add_action(
	'wp_default_scripts',
	static function ( $scripts ) {
		if ( is_admin() || empty( $scripts->registered['jquery'] ) ) {
			return;
		}
		$jquery       = $scripts->registered['jquery'];
		$jquery->deps = array_values( array_diff( $jquery->deps, array( 'jquery-migrate' ) ) );
	}
);

Good to know

After switching it on, check your pages and the browser console. If a slider or menu stops working, switch it off again.

In these packs

  • Clean up the head: Remove the links, scripts and styles WordPress adds to every page that most sites never use.
  • Performance: Small changes that save the server and the browser some work.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.