You are here:
  1. Home
  2. Blog
  3. Remove jQuery migrate if no dependencies found

Remove jQuery migrate if no dependencies found

 | Code Snippet code snippet PHP
function remove_jquery_migrate( $scripts ) {
	if ( !is_admin() && isset( $scripts->registered['jquery'] ) ) {
		$script = $scripts->registered['jquery'];
		
		if ( $script->deps ) {
			$script->deps = array_diff( $script->deps, array(
				'jquery-migrate'
			) );
		}
	}
}
add_action( 'wp_default_scripts', 'remove_jquery_migrate' );
Jem Turner jem@jemjabella.co.uk +44(0)7521056376

Follow on Instagram