wp_deregister_script

The timeline below displays how wordpress function wp_deregister_script has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Removes a registered script.
 *
 * Note: there are intentional safeguards in place to prevent critical admin scripts,
 * such as jQuery core, from being unregistered.
 *
 * @see WP_Dependencies::remove()
 *
 * @since 2.1.0
 *
 * @global string $pagenow The filename of the current screen.
 *
 * @param string $handle 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('jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone');
        if (in_array($handle, $not_allowed, true)) {
            _doing_it_wrong(__FUNCTION__, sprintf(
                /* 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.'),
                "<code>{$handle}</code>",
                '<code>wp_enqueue_scripts</code>'
            ), '3.6.0');
            return;
        }
    }
    wp_scripts()->remove($handle);
}

WordPress Version: 6.1

/**
 * Remove a registered script.
 *
 * Note: there are intentional safeguards in place to prevent critical admin scripts,
 * such as jQuery core, from being unregistered.
 *
 * @see WP_Dependencies::remove()
 *
 * @since 2.1.0
 *
 * @global string $pagenow The filename of the current screen.
 *
 * @param string $handle 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('jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone');
        if (in_array($handle, $not_allowed, true)) {
            _doing_it_wrong(__FUNCTION__, sprintf(
                /* 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.'),
                "<code>{$handle}</code>",
                '<code>wp_enqueue_scripts</code>'
            ), '3.6.0');
            return;
        }
    }
    wp_scripts()->remove($handle);
}

WordPress Version: 5.8

/**
 * Remove a registered script.
 *
 * Note: there are intentional safeguards in place to prevent critical admin scripts,
 * such as jQuery core, from being unregistered.
 *
 * @see WP_Dependencies::remove()
 *
 * @since 2.1.0
 *
 * @global string $pagenow
 *
 * @param string $handle 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('jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone');
        if (in_array($handle, $not_allowed, true)) {
            _doing_it_wrong(__FUNCTION__, sprintf(
                /* 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.'),
                "<code>{$handle}</code>",
                '<code>wp_enqueue_scripts</code>'
            ), '3.6.0');
            return;
        }
    }
    wp_scripts()->remove($handle);
}

WordPress Version: 5.7

/**
 * Remove a registered script.
 *
 * Note: there are intentional safeguards in place to prevent critical admin scripts,
 * such as jQuery core, from being unregistered.
 *
 * @see WP_Dependencies::remove()
 *
 * @since 2.1.0
 *
 * @global string $pagenow
 *
 * @param string $handle 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('jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone');
        if (in_array($handle, $not_allowed, true)) {
            $message = sprintf(
                /* 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.'),
                "<code>{$handle}</code>",
                '<code>wp_enqueue_scripts</code>'
            );
            _doing_it_wrong(__FUNCTION__, $message, '3.6.0');
            return;
        }
    }
    wp_scripts()->remove($handle);
}

WordPress Version: 5.5

/**
 * Remove a registered script.
 *
 * Note: there are intentional safeguards in place to prevent critical admin scripts,
 * such as jQuery core, from being unregistered.
 *
 * @see WP_Dependencies::remove()
 *
 * @since 2.1.0
 *
 * @param string $handle Name of the script to be removed.
 */
function wp_deregister_script($handle)
{
    _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' === $GLOBALS['pagenow'] && 'login_enqueue_scripts' !== $current_filter) {
        $not_allowed = array('jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone');
        if (in_array($handle, $not_allowed, true)) {
            $message = sprintf(
                /* 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.'),
                "<code>{$handle}</code>",
                '<code>wp_enqueue_scripts</code>'
            );
            _doing_it_wrong(__FUNCTION__, $message, '3.6.0');
            return;
        }
    }
    wp_scripts()->remove($handle);
}

WordPress Version: 5.3

/**
 * Remove a registered script.
 *
 * Note: there are intentional safeguards in place to prevent critical admin scripts,
 * such as jQuery core, from being unregistered.
 *
 * @see WP_Dependencies::remove()
 *
 * @since 2.1.0
 *
 * @param string $handle Name of the script to be removed.
 */
function wp_deregister_script($handle)
{
    _wp_scripts_maybe_doing_it_wrong(__FUNCTION__);
    /**
     * 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' === $GLOBALS['pagenow'] && 'login_enqueue_scripts' !== $current_filter) {
        $no = array('jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone');
        if (in_array($handle, $no)) {
            $message = sprintf(
                /* 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.'),
                "<code>{$handle}</code>",
                '<code>wp_enqueue_scripts</code>'
            );
            _doing_it_wrong(__FUNCTION__, $message, '3.6.0');
            return;
        }
    }
    wp_scripts()->remove($handle);
}

WordPress Version: 4.7

/**
 * Remove a registered script.
 *
 * Note: there are intentional safeguards in place to prevent critical admin scripts,
 * such as jQuery core, from being unregistered.
 *
 * @see WP_Dependencies::remove()
 *
 * @since 2.1.0
 *
 * @param string $handle Name of the script to be removed.
 */
function wp_deregister_script($handle)
{
    _wp_scripts_maybe_doing_it_wrong(__FUNCTION__);
    /**
     * 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' === $GLOBALS['pagenow'] && 'login_enqueue_scripts' !== $current_filter) {
        $no = array('jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone');
        if (in_array($handle, $no)) {
            $message = sprintf(
                /* 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.'),
                "<code>{$handle}</code>",
                '<code>wp_enqueue_scripts</code>'
            );
            _doing_it_wrong(__FUNCTION__, $message, '3.6.0');
            return;
        }
    }
    wp_scripts()->remove($handle);
}

WordPress Version: 4.6

/**
 * Remove a registered script.
 *
 * Note: there are intentional safeguards in place to prevent critical admin scripts,
 * such as jQuery core, from being unregistered.
 *
 * @see WP_Dependencies::remove()
 *
 * @since 2.1.0
 *
 * @param string $handle Name of the script to be removed.
 */
function wp_deregister_script($handle)
{
    _wp_scripts_maybe_doing_it_wrong(__FUNCTION__);
    /**
     * 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' === $GLOBALS['pagenow'] && 'login_enqueue_scripts' !== $current_filter) {
        $no = array('jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone');
        if (in_array($handle, $no)) {
            $message = sprintf(__('Do not deregister the %1$s script in the administration area. To target the front-end theme, use the %2$s hook.'), "<code>{$handle}</code>", '<code>wp_enqueue_scripts</code>');
            _doing_it_wrong(__FUNCTION__, $message, '3.6.0');
            return;
        }
    }
    wp_scripts()->remove($handle);
}

WordPress Version: 4.5

/**
 * Remove a registered script.
 *
 * Note: there are intentional safeguards in place to prevent critical admin scripts,
 * such as jQuery core, from being unregistered.
 *
 * @see WP_Dependencies::remove()
 *
 * @since 2.1.0
 *
 * @param string $handle Name of the script to be removed.
 */
function wp_deregister_script($handle)
{
    _wp_scripts_maybe_doing_it_wrong(__FUNCTION__);
    /**
     * 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' === $GLOBALS['pagenow'] && 'login_enqueue_scripts' !== $current_filter) {
        $no = array('jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone');
        if (in_array($handle, $no)) {
            $message = sprintf(__('Do not deregister the %1$s script in the administration area. To target the front-end theme, use the %2$s hook.'), "<code>{$handle}</code>", '<code>wp_enqueue_scripts</code>');
            _doing_it_wrong(__FUNCTION__, $message, '3.6');
            return;
        }
    }
    wp_scripts()->remove($handle);
}

WordPress Version: 4.3

/**
 * Remove a registered script.
 *
 * Note: there are intentional safeguards in place to prevent critical admin scripts,
 * such as jQuery core, from being unregistered.
 *
 * @see WP_Dependencies::remove()
 *
 * @since 2.6.0
 *
 * @param string $handle Name of the script to be removed.
 */
function wp_deregister_script($handle)
{
    _wp_scripts_maybe_doing_it_wrong(__FUNCTION__);
    /**
     * 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' === $GLOBALS['pagenow'] && 'login_enqueue_scripts' !== $current_filter) {
        $no = array('jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone');
        if (in_array($handle, $no)) {
            $message = sprintf(__('Do not deregister the %1$s script in the administration area. To target the frontend theme, use the %2$s hook.'), "<code>{$handle}</code>", '<code>wp_enqueue_scripts</code>');
            _doing_it_wrong(__FUNCTION__, $message, '3.6');
            return;
        }
    }
    wp_scripts()->remove($handle);
}

WordPress Version: 4.2

/**
 * Remove a registered script.
 *
 * Note: there are intentional safeguards in place to prevent critical admin scripts,
 * such as jQuery core, from being unregistered.
 *
 * @see WP_Dependencies::remove()
 * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
 *
 * @since 2.6.0
 *
 * @param string $handle Name of the script to be removed.
 */
function wp_deregister_script($handle)
{
    _wp_scripts_maybe_doing_it_wrong(__FUNCTION__);
    /**
     * 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' === $GLOBALS['pagenow'] && 'login_enqueue_scripts' !== $current_filter) {
        $no = array('jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone');
        if (in_array($handle, $no)) {
            $message = sprintf(__('Do not deregister the %1$s script in the administration area. To target the frontend theme, use the %2$s hook.'), "<code>{$handle}</code>", '<code>wp_enqueue_scripts</code>');
            _doing_it_wrong(__FUNCTION__, $message, '3.6');
            return;
        }
    }
    wp_scripts()->remove($handle);
}

WordPress Version: 3.7

/**
 * Remove a registered script.
 *
 * Note: there are intentional safeguards in place to prevent critical admin scripts,
 * such as jQuery core, from being unregistered.
 *
 * @see WP_Dependencies::remove()
 * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
 *
 * @since 2.6.0
 *
 * @param string $handle Name of the script to be removed.
 */
function wp_deregister_script($handle)
{
    global $wp_scripts;
    if (!is_a($wp_scripts, 'WP_Scripts')) {
        if (!did_action('init')) {
            _doing_it_wrong(__FUNCTION__, sprintf(__('Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.'), '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>'), '3.3');
        }
        $wp_scripts = new WP_Scripts();
    }
    /**
     * 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' === $GLOBALS['pagenow'] && 'login_enqueue_scripts' !== $current_filter) {
        $no = array('jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone');
        if (in_array($handle, $no)) {
            $message = sprintf(__('Do not deregister the %1$s script in the administration area. To target the frontend theme, use the %2$s hook.'), "<code>{$handle}</code>", '<code>wp_enqueue_scripts</code>');
            _doing_it_wrong(__FUNCTION__, $message, '3.6');
            return;
        }
    }
    $wp_scripts->remove($handle);
}