How7o
  • Home
  • Tools
  • Prank Screens
  • Contact
  • Blog
Reading: How to Deregister or Remove a CSS File in WordPress (wp_dequeue_style Not Working)
Share
Subscribe Now
How7oHow7o
Font ResizerAa
  • Marketing
  • OS
  • Features
  • Guide
  • Complaint
  • Advertise
Search
  • Home
  • Tools
  • Prank Screens
  • Contact
  • Blog
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.
How7o > Blog > Web Development > How to Deregister or Remove a CSS File in WordPress (wp_dequeue_style Not Working)
Web Development

How to Deregister or Remove a CSS File in WordPress (wp_dequeue_style Not Working)

how7o
By how7o
Last updated: May 10, 2026
6 Min Read
WordPress wp_dequeue_style priority 9999 runs after plugin enqueues
SHARE

When wp_dequeue_style not working turns up with a plugin-added stylesheet (typically an outdated Font Awesome you want to replace), the real culprit is hook priority. Your dequeue fires at the default priority 10, at the same time the plugin is registering its enqueue, and the race can go either way. Bumping your hook to priority 9999 runs your removal after every plugin has finished — and the style stays out.

Contents
  • TL;DR
  • Why the default-priority version fails
  • Finding the handle
  • Replacing the removed style with a newer version
  • Admin and editor contexts
  • Same pattern for scripts
  • Frequently asked questions
  • Related guides
  • References

Last verified: 2026-04-23 on WordPress 6.5 and PHP 8.3. Originally published 2023-12-16, rewritten and updated 2026-04-23.

TL;DR

add_action( 'wp_enqueue_scripts', function () {
    wp_dequeue_style( 'font-awesome' );
    wp_deregister_style( 'font-awesome' );
}, 9999 );

Why the default-priority version fails

// Fails silently — priority 10 runs alongside the plugin's enqueue
add_action( 'wp_enqueue_scripts', function () {
    wp_dequeue_style( 'font-awesome' );
    wp_deregister_style( 'font-awesome' );
} );

WordPress calls every wp_enqueue_scripts callback in ascending priority order. If the offending plugin hooks at priority 10 and so do you, PHP runs whichever registered first — which varies with load order. Even if your dequeue runs later, the plugin may register its style again later in the hook chain, putting it back into the queue. The priority 9999 form sidesteps both problems: your callback runs last, after every plugin has already enqueued.

wordpress wp_dequeue_style not working — priority 9999 runs after plugin enqueues

Finding the handle

View the page source and search for the stylesheet. WordPress marks every enqueued style with an id attribute of {handle}-css:

<link rel='stylesheet' id='font-awesome-css' href='...'>
                             ^^^^^^^^^^^^^ handle is 'font-awesome'

Some plugins use less predictable names (fa-css, my-plugin-fontawesome, swfa-style) — the id attribute is authoritative. Strip the trailing -css and you have the handle.

Replacing the removed style with a newer version

add_action( 'wp_enqueue_scripts', function () {
    wp_dequeue_style( 'font-awesome' );
    wp_deregister_style( 'font-awesome' );

    wp_enqueue_style(
        'how7o-font-awesome',
        get_stylesheet_directory_uri() . '/assets/fontawesome/css/all.min.css',
        array(),
        '6.5.2'
    );
}, 9999 );

Ship your own copy and re-enqueue under a different handle. Using a different handle (how7o-font-awesome instead of font-awesome) avoids conflict with any plugin that later checks wp_style_is('font-awesome') and tries to re-enqueue.

Admin and editor contexts

  • wp_enqueue_scripts — frontend.
  • admin_enqueue_scripts — admin pages.
  • login_enqueue_scripts — /wp-login.php.
  • enqueue_block_editor_assets — block editor iframe.

Hook into whichever context the offending style is loading in. If the plugin enqueues globally, you’ll need to hook multiple contexts to suppress it everywhere.

Same pattern for scripts

add_action( 'wp_enqueue_scripts', function () {
    wp_dequeue_script( 'slick' );
    wp_deregister_script( 'slick' );
}, 9999 );

Identical shape. The JS equivalent of the -css id suffix is -js — look for id="slick-js" on the <script> tag.

Frequently asked questions

Why is wp_dequeue_style not working?

Your hook is firing before the plugin registers its own enqueue. WordPress runs wp_enqueue_scripts callbacks in priority order — default 10 — so a dequeue at priority 10 runs side-by-side with the plugin’s enqueue and one of them wins unpredictably. Raise your hook’s priority (add_action( 'wp_enqueue_scripts', ..., 9999 )) so your dequeue always runs after every plugin has finished registering.

What’s the difference between wp_dequeue_style and wp_deregister_style?

wp_dequeue_style removes the style from the output queue for the current request — it doesn’t print a <link> tag. wp_deregister_style removes the handle from WordPress’s registry entirely, so nothing else can re-enqueue it (via a dependency chain or a plugin’s later hook). Call both to be safe: dequeue for this request, deregister so no re-enqueue can bring it back.

How do I find the handle to dequeue?

Inspect your page’s source and look for id="{handle}-css" on the <link> tag — WordPress appends -css to every handle. If the offending style is <link id="font-awesome-css" ...>, the handle is font-awesome. For scripts the suffix is -js. Some plugins use less obvious handles (fa-css, my-plugin-fontawesome) — the page source is authoritative.

Does this also work for scripts?

Yes — swap wp_dequeue_style/wp_deregister_style for wp_dequeue_script/wp_deregister_script. The priority rule is the same (fire after all plugin enqueues, typically 9999). Hook into wp_enqueue_scripts for frontend scripts, admin_enqueue_scripts for admin.

Is the priority number 9999 magic?

No — any number higher than every plugin’s priority works. 9999 is the pragmatic convention because it’s almost certainly higher than any plugin would reach. If you specifically need to run after another plugin that’s also using PHP_INT_MAX or a similar extreme, use a still-later hook like wp_print_styles (which fires after wp_enqueue_scripts has finished).

Related guides

  • How to Compile Multiple CSS into One CSS with Laravel + Vite — bundle pipeline thinking, different ecosystem.
  • How to Disable Revisions and Autosave in WordPress — related “turn off this WP feature” pattern.
  • How to Apply pre_get_posts on Custom Post Types in WordPress — another priority-matters hook pattern.
  • How to Display Different Menus to Logged-In Users in WordPress — another functions.php customization.

References

WordPress developer reference for wp_dequeue_style and wp_deregister_style: developer.wordpress.org/reference/functions/wp_dequeue_style.

TAGGED:CSSperformancephptroubleshootingwordpress

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article WordPress posts by date range — date_query with after/before/inclusive How to Get Posts by Date Range in WordPress
Next Article WordPress too many redirects HTTPS — Cloudflare flexible SSL loop and the wp-config fix Fix ERR_TOO_MANY_REDIRECTS in WordPress After Switching to HTTPS
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow

Subscribe Now

Subscribe to our newsletter to get our newest articles instantly!
Most Popular
Display PHP errors — ini_set + php.ini configuration
How to Display PHP Errors
May 10, 2026
PHP convert string to uppercase — strtoupper and mb_strtoupper
How to Convert a String to Uppercase in PHP
May 10, 2026
PHP string to float conversion with cast, regex cleanup, NumberFormatter
How to Convert a String to Float in PHP
May 10, 2026
PHP merge arrays without duplicates — union operator and array_unique
How to Combine Two Arrays Without Duplicates in PHP
May 10, 2026
PHP delete array element — unset, array_splice, array_filter, array_search
How to Delete an Element from a PHP Array
May 10, 2026

You Might Also Like

Fake Windows update prank — fullscreen blue Windows update screen on an office laptop
OS

How to Prank a Coworker With a Fake Windows Update

9 Min Read
WordPress $wpdb->insert_id — read after $wpdb->insert or $wpdb->query INSERT
Web Development

How to Retrieve the Last Inserted Row ID in WordPress

7 Min Read
Laravel validate in rule — restricting input to an allow-list with in: and Rule::in
Web Development

Laravel Validate Input to Specific Values (in Rule)

7 Min Read
WooCommerce My Account login form hooks — five positions for injecting content
Web Development

How to Add a Link or Button After the Login Form in WooCommerce

6 Min Read
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Latest News

  • SEO Audit Tool
  • Client ReferralsNew
  • Execution of SEO
  • Reporting Tool

Resouce

  • Google Search Console
  • Google Keyword Planner
  • Google OptimiseHot
  • SEO Spider

Get the Top 10 in Search!

Looking for a trustworthy service to optimize the company website?
Request a Quote
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?