wp_deregister_script( string $handle )

Removes a registered script.


Note: there are intentional safeguards in place to prevent critical admin scripts, such as jQuery core, from being unregistered.

See also


Name of the script to be removed.


function wp_deregister_script( $handle ) {
	global $pagenow;

	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );

	 * Do not allow accidental or negligent de-registering of critical scripts in the admin.
	 * Show minimal remorse if the correct hook is used.
	$current_filter = current_filter();
	if ( ( is_admin() && 'admin_enqueue_scripts' !== $current_filter ) ||
		( 'wp-login.php' === $pagenow && 'login_enqueue_scripts' !== $current_filter )
	) {
		$not_allowed = array(

		if ( in_array( $handle, $not_allowed, true ) ) {
					/* translators: 1: Script name, 2: wp_enqueue_scripts */
					__( 'Do not deregister the %1$s script in the administration area. To target the front-end theme, use the %2$s hook.' ),

	wp_scripts()->remove( $handle );



User Contributed Notes

  1. Skip to note 3 content

    Deregistering will not dequeue the script handle in the strict sense.
    You may use wp_deregister_script ( 'script-handle' ); followed by wp_register_script if you want to change the URL of an already enqueued script without changing the order in which it is enqueued, for example when a parent theme has not specified dependencies correctly.

You must log in before being able to contribute a note or feedback.