Remove Unused CSS in WordPress: Before/After on a Real Page (WP Rocket Test)
To remove unused CSS in WordPress, use a plugin that builds a per-page “used CSS” file and drops the rest. WP Rocket’s Remove Unused CSS, FlyingPress and Perfmatters all do it. If you’d rather not pay, try the free Debloat plugin, or unload whole stylesheets page by page with Asset CleanUp or a few lines of code. I ran WP Rocket’s version on a real page and measured before and after: LCP went from 1.7 s to 1.1 s, and the CSS and JavaScript the browser loaded dropped from 332 kB (30% of it used) to 191 kB (49% used). Here’s how it works, how to check your own pages, and what can go wrong.
Before and after Remove Unused CSS (same page, same server)
| Before (WP Rocket, no RUCSS) | After RUCSS | |
|---|---|---|
| PageSpeed mobile | 100 | 100 |
| First Contentful Paint | 1.1 s | 1.0 s |
| Largest Contentful Paint | 1.7 s | 1.1 s |
| Speed Index | 2.3 s | 1.0 s |
| CSS + JS loaded (Coverage) | 332 kB, 30% used | 191 kB, 49% used |
| Time to generate used CSS | – | 8 minutes |
The score was already 100, so PageSpeed hid the improvement. LCP and Speed Index show it. If LCP is the number you are chasing, my guide to improving Largest Contentful Paint in WordPress covers the fixes beyond CSS.
Tested: WP Rocket 3.24 (trial), WordPress 7.1.4, PHP 8.5, Kadence theme, Nginx on an aaPanel VPS in Hong Kong (YottaSrc), Cloudflare proxied. One blog post on fashionlookbd.shop (noindex test site), PageSpeed Insights mobile (middle of 3 runs), Chrome DevTools Coverage, 8–9 November 2026 (WP Rocket runs on 9 November), Coverage measured from Dhaka. “Before” is WP Rocket with page cache, minify, lazy load and Delay JS already on, so the only change measured is Remove Unused CSS.
Table of Contents
What unused CSS is, and why WordPress has so much
Every stylesheet a page loads has to download and be parsed before the browser can paint. “Unused CSS” is the rules in those files that the current page never uses: slider styles on a page without a slider, WooCommerce styles on a blog post, every block’s styles when you used three blocks.
WordPress makes this worse by design. Themes ship one stylesheet for every template. Plugins usually load their CSS on every page, just in case. Page builders add more. None of it breaks anything; it just makes the browser download and process code it then ignores, which pushes back First Contentful Paint and LCP, most on slow phones.
How to find unused CSS on your page
1. PageSpeed Insights
Run your URL on PageSpeed Insights (mobile). Look for Reduce unused CSS, the audit most people mean when they search how to reduce unused CSS in WordPress. It lists each stylesheet and how many KiB of it went unused. Lighthouse’s current code only flags a stylesheet once more than 10 KiB of it is unused. That’s why the audit can pass even when Coverage shows plenty of waste.
That happened on my test page: the audit passed (green) before Remove Unused CSS, both with no cache plugin and with WP Rocket’s basic settings. PageSpeed had nothing to complain about, yet 70% of the loaded CSS and JS was unused. Don’t rely on the audit alone.

2. Chrome DevTools Coverage (the honest number)
Open the page in an incognito window, press F12, then Ctrl+Shift+P (Cmd+Shift+P on Mac), type “coverage” and choose Show Coverage. Click the reload button in the Coverage panel. You get every CSS and JS file with Total Bytes, Unused Bytes and a usage bar (Chrome’s docs use green for used and gray for unused), and a summary at the bottom. Filter by CSS if you only want stylesheets.

My summary said 99.9 kB of 332 kB used (30%). That’s the number to beat. Coverage counts what the page used during the load; scrolling or opening a menu uses more, so 100% is never the goal.
Ways to remove unused CSS in WordPress
| Method | How it works | Cost | Risk |
|---|---|---|---|
| WP Rocket: Remove Unused CSS | Cloud service builds used CSS per page, inlines it, removes the stylesheets | From $5/month (billed yearly) | Medium: dynamic elements can lose styles |
| FlyingPress: Remove Unused CSS | Cloud builds used CSS, inlines it, loads full stylesheets later when the browser is idle | Paid | Lower: full CSS still arrives |
| Perfmatters: Remove Unused CSS | Generated on your server, saved as a file | Paid (no trial) | Medium |
| Asset CleanUp (free) | You switch whole stylesheets off per page or post type | Free | Depends on you; nothing automatic |
| Load CSS asynchronously / critical CSS | Inline only above-the-fold CSS, load the rest without blocking | In WP Rocket, FlyingPress, others | Low; doesn’t reduce bytes |
I’ve tested the WP Rocket method on this page. FlyingPress is what webpickr.com runs on (my FlyingPress settings cover its option); I’ll add same-page numbers for it in my next test session. LiteSpeed Cache can also generate used CSS (UCSS, through QUIC.cloud) on any server; only its page cache needs a LiteSpeed server.
Since then I have tested two more on the same page: xSpeed Cache Pro’s Remove Unused CSS cut the theme CSS from 85.7 KB to 38.9 KB but made LCP worse (1.2 s to 1.7 s), as I show in my xSpeed Cache review (Pro license provided by WPDeveloper), and NitroPack keeps Remove unused CSS for its Plus plan, which I found in my NitroPack review.
Free plugins that remove unused CSS (and which don’t)
Among the well-known free plugins, only two actually remove unused CSS rules: Debloat, a free plugin that does the work on your own server, and LiteSpeed Cache, whose UCSS feature is free within QUIC.cloud’s small monthly quota. The popular free cache plugins don’t do it at all. Asset CleanUp switches off whole files, not unused rules.
| Plugin | Free version removes unused CSS? | How | On my test page |
|---|---|---|---|
| Debloat 1.4.0 | Yes | “Remove Unused CSS (Advanced)”, processed on your own server, no outside service. 30,000+ active installs, no paid version. | Not tested |
| LiteSpeed Cache 7.9.3 | Yes, within a quota | UCSS is built by QUIC.cloud: 5 units per request, and the free plan gets 100 units a month from 1 December 2026, shared with other services. Works on any server; the page cache needs a LiteSpeed server or QUIC.cloud CDN. | Not tested |
| Asset CleanUp | Whole files only | You switch stylesheets off per page or post type. | Not tested |
| Autoptimize | No | Aggregates and minifies CSS, has a “Remove WordPress blocks CSS” option; critical CSS is pasted by hand or comes from a paid service. | With WP Super Cache: PageSpeed 100, LCP 1.7 s, unused-CSS audit passed |
| W3 Total Cache | No (Pro unloads whole files) | Pro’s Remove CSS/JS drops whole files, not single rules. | Free version tested; no such option |
| Jetpack Boost | No | Free plan generates critical CSS manually; it doesn’t remove unused CSS. | Tested (critical CSS, not unused CSS) |
| WP-Optimize | No | Minify and combine; no unused-CSS feature in free or Premium. | Free version tested |
| WP Super Cache, WP Fastest Cache | No | Page cache only (WP Fastest Cache keeps its extras for Premium). | Tested; WP Super Cache alone left the unused-CSS audit flagged |
The paid route is where this feature lives: WP Rocket, FlyingPress, Perfmatters, xSpeed Cache Pro and NitroPack’s Plus plan. Of those I measured WP Rocket (the before/after below) and xSpeed Cache Pro (it made LCP worse). If you want a free stack that still gets fast, my test of the best free WordPress optimization plugins shows what WP Super Cache plus Autoptimize reached without any unused-CSS removal. Critical CSS, which Boost and Autoptimize offer instead, is covered in my critical CSS guide.
How to remove unused CSS without a plugin
Without a plugin you have two real options: stop whole stylesheets from loading on pages that don’t need them, with a few lines in a child theme, or strip unused rules out of your own stylesheet with a tool like PurgeCSS. The second only suits a custom theme you control, because it misses styles that appear after a click.
1. Find the stylesheet’s handle
Open the page, press Ctrl+U and search for stylesheet. Each file looks like <link rel='stylesheet' id='contact-form-7-css' …>. The handle is the id without -css, here contact-form-7. Use the Coverage panel from earlier to see which of those files the page barely uses.
2. Dequeue it where it isn’t needed
Add a snippet like this to a child theme’s functions.php, so a theme update doesn’t wipe it out:
// Child theme functions.php: load a contact form's CSS only on /contact/
add_action( 'wp_enqueue_scripts', function () {
if ( ! is_page( 'contact' ) ) {
wp_dequeue_style( 'contact-form-7' );
}
}, 100 );
Priority 100 makes it run after the plugin has added its file. Typical targets are form and slider CSS outside the pages that use them, and WooCommerce CSS outside the shop. Then check the page logged out, in a private window.
Be careful with core styles. Many guides tell you to dequeue wp-block-library, but if your posts are built with blocks (webpickr.com’s are), that file styles them and removing it breaks the layout. Recent WordPress versions can also load block styles only for the blocks a page uses, so there’s less to gain there than older guides suggest.
3. PurgeCSS or PurifyCSS (custom themes only)
These command-line tools read your HTML and templates and write a smaller stylesheet with only the selectors they find. PurgeCSS is actively maintained (version 9.1.0, November 2026); PurifyCSS, which older tutorials mention, hasn’t had a release since 2017, and UnCSS is another option. The catch: they can’t see classes that JavaScript adds later (menus, popups, sliders), so you have to safelist those, and you need to run the tool again after every theme or plugin update. That’s why plugins build used CSS per page instead.
I haven’t done any of this by hand on my test page, so I have no numbers for it. If you’d rather not touch code, Asset CleanUp does step 2 with checkboxes.
How to remove unused CSS with WP Rocket (step by step)
WP Rocket 3.24 has a new layout. Its documentation (written before 3.24) still says File Optimization; on my install the option was under Page Optimization → JavaScript & CSS, inside Optimize CSS delivery.
- Check the requirements first. Remove Unused CSS is built by WP Rocket’s servers, so they have to reach your site. Your license must be active, the site must be public (no maintenance mode or password), and nothing may block their bot. On my test site Cloudflare’s Bot Fight Mode was off, and I made sure WP-Cron wasn’t disabled in wp-config (no active
DISABLE_WP_CRONline). - Turn on Optimize CSS delivery and choose Remove Unused CSS. It’s one of two buttons; the other is Load CSS Asynchronously. Only one can be active. Leave the CSS safelist empty for now.
- Save, then visit the pages. Generation starts when a page is visited. I opened the test URL two or three times in an incognito window.
- Wait. WP Rocket sends pages in batches and checks back every minute. Mine took 8 minutes. Every few minutes I reloaded a wp-admin page: pages served from cache don’t trigger WP-Cron, admin pages do.
- Confirm it’s applied. View the page source (Ctrl+U) and search for
wpr-usedcss. If it’s there, the used CSS is inlined and the original stylesheets are gone. - Clear the cache and test properly: layout, icons, hover states, the mobile menu, forms, sliders, logged out and on a phone.


<style id="wpr-usedcss"> right after the title.My before and after results
Same page, same settings except Remove Unused CSS, measured on the same evening.



The used amount barely changed (99.9 kB → 94.1 kB), which is what you’d expect: the page still needs the same styles. The total dropped by 141 kB, and almost all of that (about 135 kB) was code the page never used. LCP fell by 0.6 s and Speed Index by more than half. PageSpeed’s mobile test already simulates a mid-range phone on a slow connection, so this is roughly the gain a phone visitor gets.
For context, the same page with no cache plugin had LCP 2.5 s. Free plugins without this feature stayed around 1.7–2.8 s; WP Rocket with Remove Unused CSS was the only setup to reach 1.1 s. More in Autoptimize vs WP Rocket, where the same comparison covers a free stack.
When Remove Unused CSS breaks something (and how to fix it)
I didn’t add any safelist entries for my Kadence test page. Real sites often need some. The usual suspects:
- Things that appear after a click or scroll: mobile menus, mega-menus, modals, sliders, tabs, cookie banners, WooCommerce notices. Their classes aren’t on the page when the used CSS is built, so their styles get removed.
- Classes added by JavaScript, especially random or numbered ones.
- Icon fonts showing as squares.
- Firewall or challenge pages: if a security plugin or Cloudflare shows WP Rocket’s bot a challenge, the used CSS is built from the wrong page.
Fixes, in order:
- Add the class, ID, file or font to the CSS safelist, one per line. WP Rocket’s troubleshooting guide accepts patterns such as
.menu-open(.*)for classes, a file path, or@FontNamefor a font family. - To test whether safelisting can fix it at all, add
(.*)alone. If the page looks right with that, narrow it down; if not, the problem is elsewhere. - Changing the safelist clears all used CSS and rebuilds it, so wait again before judging.
- Still broken? Switch to Load CSS Asynchronously. You keep most of the paint gain without removing anything.
Prevent unused CSS in the first place
- Use a lightweight theme and only the plugins you need. Every plugin that styles the front end adds a stylesheet.
- Turn on your page builder’s performance options (Elementor’s Improved CSS Loading feature, Divi’s dynamic CSS). Note that WP Rocket switches Divi’s dynamic CSS off when Remove Unused CSS is on.
- Use a facade for YouTube embeds instead of loading the full player.
- Load contact-form and slider plugins only on the pages that use them (Asset CleanUp can do this for free).
- On non-shop pages, WooCommerce and block-library styles are common leftovers; Asset CleanUp or Perfmatters’ Script Manager can unload them.
Remove unused CSS vs critical CSS vs async CSS
| What it does | Bytes saved | Break risk | |
|---|---|---|---|
| Remove unused CSS | Keeps only the rules a page uses, drops the rest | Most | Highest |
| Critical CSS | Inlines the above-the-fold rules, loads the full CSS later | None | Low (brief unstyled flash if wrong) |
| Load CSS asynchronously | WP Rocket’s name for critical CSS + async loading | None | Low |
If you can make Remove Unused CSS work, it wins. Use the async option as the fallback. FlyingPress sits in between: it inlines the used CSS and loads the full stylesheets later, which is why its breakage risk is lower. I measured what critical CSS did on its own test page, plugin by plugin, in my guide to critical CSS in WordPress.
Things to know before you rely on it
- It isn’t instant. Until a page’s used CSS exists, that page loads normally. New posts take a visit and a few minutes.
- WP Rocket rebuilds used CSS every 30 days, and whenever you change the safelist.
- If you use Mobile Cache, mobile visitors get their own used CSS.
- Don’t run two used-CSS features at once: WP Rocket turns its own off if Perfmatters’ Remove Unused CSS is active.
- If the generated used CSS is tiny (under 150 bytes), WP Rocket doesn’t apply it.
- It needs the outside world to reach your site. A staging site behind a password won’t work.
- PageSpeed may still flag some unused CSS afterwards. Small leftovers under the audit’s threshold aren’t worth chasing.
Related: my full WP Rocket settings, Autoptimize settings for the free route, and reducing TTFB if the server side is your bottleneck. Ready to try it? WP Rocket has a 14-day trial.
FAQ
Is it safe to remove unused CSS in WordPress?
Yes, if you test after turning it on. The risk is losing styles for things that appear later, such as menus, popups and sliders. Fix those with the safelist, or switch to Load CSS Asynchronously.
Why can’t I remove 100% of unused CSS?
Coverage counts only what the page used while loading. Menus, hover states and other screen sizes need rules that weren’t used at that moment. On my test page about half (51%) of the CSS and JS was still unused after Remove Unused CSS, and that’s normal.
How long does WP Rocket take to remove unused CSS?
It depends on how many pages are queued and how quickly WP-Cron runs. WP Rocket processes pages in batches and checks every minute. My test page got its used CSS in 8 minutes after I visited it.
Does removing unused CSS help SEO?
Indirectly. It speeds up how quickly content appears (Largest Contentful Paint is one of Google’s Core Web Vitals). On my test page LCP improved from 1.7 s to 1.1 s. It won’t rank a page by itself.
Can I remove unused CSS without a plugin?
Partly. Find the files with Chrome DevTools Coverage, then dequeue whole stylesheets in a child theme’s functions.php on pages that don’t need them. Tools like PurgeCSS can strip unused rules from your own theme’s stylesheet, but they miss classes that JavaScript adds later. Building used CSS per page automatically needs a plugin such as WP Rocket, FlyingPress, Perfmatters or the free Debloat.
What is the difference between Remove Unused CSS and Load CSS Asynchronously in WP Rocket?
Remove Unused CSS keeps only the rules each page uses and removes the stylesheets, so fewer bytes load. Load CSS Asynchronously inlines the critical CSS and loads the full stylesheets without blocking, so nothing is removed and it breaks less often.
Is there a free plugin to remove unused CSS?
Yes. Debloat is free on wordpress.org and removes unused CSS on your own server, and LiteSpeed Cache’s UCSS is free within QUIC.cloud’s monthly quota. Most free cache plugins, including WP Super Cache, WP Fastest Cache, W3 Total Cache, Autoptimize and WP-Optimize, don’t remove unused CSS. I haven’t tested Debloat or LiteSpeed on my test page.
