Code Snippet: Disable jQuery Migrate


I like to keep my installs trim and scripts to minimum, i know nothing i run needs the migration tool, so let’s knock that one on the head. If you don’t know what this script does or is for, it’s probably best to leave it be.

	add_action( 'wp_default_scripts', 'on_wp_default_scripts', 2000 );
	public function on_wp_default_scripts( $wp_script_instance ) {
		
		if( !isset( $wp_script_instance->registered['jquery'] ) )
			return;
		
		foreach( $wp_script_instance->registered['jquery']->deps as $k => $script ) {
			
			if( 'jquery-migrate' !== $script ) 
				continue;

			unset( $wp_script_instance->registered['jquery']->deps[$k] );
			break;
		}
	}
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s