How7o
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: How to Deregister or Remove a CSS File in WordPress (wp_dequeue_style Not Working)
Share
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
  • 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.

FacebookLike
XFollow
PinterestPin
InstagramFollow
Most Popular
Laravel Eloquent ORM — a model class mapping to a database table with query methods
Laravel Eloquent ORM: The Complete Guide to Querying Your Database
June 16, 2026
Set vi as the default editor in Ubuntu — a terminal opening the vim editor
How to Set vi (Vim) as the Default Editor in Ubuntu
June 8, 2026
rsync says ALL DONE but files are missing — a terminal showing ALL DONE next to an empty folder
rsync Says “ALL DONE” but Files Are Missing: How to Verify
June 8, 2026
Migrate a website to a new server with rsync — files copying from an old server to a new one over SSH
How to Migrate a Website to a New Server With rsync
June 8, 2026
Bun runtime — faster JS toolkit replacing npm in Laravel projects
How to Install Bun Runtime on Ubuntu (And Use It in a Laravel Project)
May 24, 2026

You Might Also Like

WooCommerce homepage filter to hide out of stock products
Web Development

Hide Out of Stock Products from Homepage in WooCommerce (Keep Them Visible Elsewhere)

5 Min Read
XAMPP MySQL command line on Windows — fixing 'mysql' not recognized
OS

How to Access MySQL from Command Line in XAMPP on Windows

7 Min Read
Capitalize all words in JavaScript with a ucwords-style function
Web Development

Capitalize All Words in JavaScript (ucwords Equivalent) + First Letter Uppercase

6 Min Read
JavaScript check valid URL — URL constructor vs regex
Web Development

How to Check if a JavaScript String Is a Valid URL

5 Min Read
How7o

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

Tools

  • Age Calculator
  • Word Counter
  • Image Upscaler
  • Password Generator
  • QR Code Generator
  • See all tools→

Pranks

  • Fake Blue Screen Prank
  • Hacker Typer
  • Fake iMessage Generator
  • Windows XP Crash Prank
  • Windows 11 Update Prank
  • 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?