How7oHow7o
  • Home
  • Tools
    • All Tools
    • Image Tools
    • Text & String Tools
    • Video Tools
    • Developer Tools
    • PDF Tools
    • Calculators & More
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: How to Deregister or Remove a CSS File in WordPress (wp_dequeue_style Not Working)
Share
Notification Show More
Font ResizerAa
How7oHow7o
Font ResizerAa
  • Tools
  • Prank Screens
  • Learn
  • Blog
Search
  • Home
  • Tools
    • All Tools
    • Image Tools
    • Text & String Tools
    • Video Tools
    • Developer Tools
    • PDF Tools
    • Calculators & More
  • Prank Screens
  • Learn
  • Blog
  • Contact
Follow US
© 2024–2026 How7o. All rights reserved.
How7o > Free Laravel, PHP, WordPress & Server Tutorials > 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.
[mc4wp_form]
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.

You Might Also Like

WordPress check if user is logged in with is_user_logged_in()
Web Development

How to Check If a User Is Logged In in WordPress

7 Min Read
Laravel 403 forbidden on shared hosting — root htaccess rewrite into public folder
Web Development

Fix “403 Forbidden” on Laravel Shared Hosting

8 Min Read
Install and configure Redis on Ubuntu for Laravel and WordPress
Server Management

How to Install and Configure Redis on Ubuntu (for Laravel & WordPress)

10 Min Read
WordPress disable revision and autosave — wp-config constants and wp_print_scripts dequeue
Web Development

How to Disable Revisions and Autosave in WordPress

8 Min Read
How7oHow7o

Free browser-based tools, prank screens, and step-by-step tech tutorials. No signup, nothing uploaded.

  • Private by design — your files never leave your device
  • Instant — no signup, no install, no waiting
  • Always free — no trials, no watermarks, no paywalls

Tools

  • PDF Editor
  • Image Upscaler
  • JPEG Compressor
  • Password Generator
  • QR Code Generator
  • Video Trimmer
  • See all tools →

Pranks

  • Cracked Screen Prank
  • Fake Blue Screen (BSOD)
  • Fake Console Update Screen
  • Fake Disk Format
  • Fake Low Battery
  • Fake Virus Scan
  • See all prank screens →

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service
  • Sitemap
© 2024–2026 How7o. All rights reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?