Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared Managed Cloud India
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Best lists Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Speed & performance · Guide

How to Remove Unused CSS in WordPress

Short answer

To remove unused CSS in WordPress, first find it with PageSpeed Insights and Chrome DevTools Coverage, which shows used and unused bytes for each stylesheet. Then enable Remove Unused CSS in WP Rocket or Perfmatters so each page loads only the CSS it uses, or dequeue whole stylesheets with wp_dequeue_style() in code. Clear every cache and check each key page, including sliders and popups, before you call the job done.

Key takeaways

  • Unused CSS is stylesheet code a page downloads but never uses to paint what visitors see.
  • Lighthouse lists stylesheets with unused CSS when the potential saving is 2 KiB or more.
  • Chrome DevTools Coverage shows used and unused bytes for each stylesheet on a page.
  • WP Rocket and Perfmatters can generate used CSS per page and delay or drop the rest.
  • Always test sliders, popups, and forms after cleanup, because rules used after interaction can be stripped by mistake.

What is unused CSS in WordPress?

Unused CSS is any style rule your page downloads but never uses to paint what visitors see.

A theme or plugin often loads one large stylesheet for the whole site, even when a page uses only part of it. The rest counts as unused CSS for that page, and the browser still downloads and parses it.

WP Rocket names bloated plugins, page builders, themes, and font icons as the main sources of unused CSS on WordPress sites (How to Remove Unused CSS on WordPress).

A rule can be unused on one page and needed on another, so unused CSS is always judged page by page, not site by site.

PageSpeed Insights flags the problem as “Reduce unused CSS” when it finds more than 10 KB of unused CSS on a page, according to WP Rocket (How to Remove Unused CSS on WordPress).

How does unused CSS slow down your site?

Unused CSS slows your site because the browser must download, parse, and process every stylesheet before it can show content.

By default, a browser must download, parse, and process all external stylesheets before it can render any content, as Chrome for Developers explains (Remove unused CSS). Each extra stylesheet adds network trips that delay the first thing visitors see. That delay is why unused CSS shows up in render-blocking resource reports.

Unused CSS also slows the render tree, the structure the browser builds by matching CSS rules to each node in the page. Chrome for Developers notes that the more unused CSS there is, the more time the browser may spend calculating styles for each node (Remove unused CSS).

The effect reaches the metrics Google measures. WP Rocket states that unused CSS affects Largest Contentful Paint (LCP) and Total Blocking Time (TBT), two of the numbers behind Core Web Vitals (How to Remove Unused CSS on WordPress).

It also adds bytes to every page load, which is one reason to watch your network payload size.

How do you find unused CSS on your site?

Run PageSpeed Insights on the page, then open Chrome DevTools Coverage to see which files and rules are unused.

  1. Open PageSpeed Insights and run it on the page you want to fix.
  2. Open the “Reduce unused CSS” result and note each stylesheet it lists, plus the saving it claims.
  3. In Chrome, open the same page, press Ctrl+Shift+I on Windows or Cmd+Option+I on Mac, then press Ctrl+Shift+P or Cmd+Shift+P and type “coverage”.
  4. Choose “Show Coverage”, then click the Reload button in the Coverage panel to start a fresh recording.
  5. Read the table: the Total Bytes column shows each file size, and the Unused Bytes column shows what was never used.
  6. Click a row to open the file in the Sources panel and see unused lines marked for you.

The Coverage panel helps you find unused JavaScript and CSS code, and removing that code can speed up page load, according to Chrome DevTools documentation (Coverage: Find unused JavaScript and CSS).

You can set the scope to Per function or Per block from the drop-down at the top of the panel (Coverage: Find unused JavaScript and CSS).

Coverage only records what ran while you watched the page, so interact with it first: open menus, trigger popups, and scroll. A rule that looks unused may only appear after a click.

Check the home page, a blog post, and a page with a form, since each loads different styles. If you want the wider picture, read the Core Web Vitals guide before you start changing files.

What do you need before you remove unused CSS?

You need a full backup, a staging copy, and a list of the pages that use sliders, popups, forms, and other interactive parts.

  • A full backup of files and database, so you can restore the site if a change breaks the layout.
  • A staging copy of the site, so you can test the cleanup before visitors see it.
  • A list of key page types: home, a post, a page with a form, a page with a slider, and the checkout page if you sell anything.
  • A note of the current PageSpeed Insights result for each of those pages, so you can compare before and after.
  • Access to clear every cache: your cache plugin, your CDN, and your browser cache.

Work on staging first and publish the change only after every key page looks right. Budget one focused session for the cleanup and a second pass to check pages, rather than rushing both into one sitting.

How do you remove unused CSS with WP Rocket?

Enable Optimize CSS delivery and choose Remove Unused CSS in WP Rocket, then let it generate used CSS for each page.

  1. Install and activate WP Rocket, then go to Settings > WP Rocket in your WordPress admin.
  2. Open the File Optimization tab. In WP Rocket 3.24 the dashboard changed, and these options now sit under Page Optimization, in the JavaScript and CSS section, according to WP Rocket's own documentation updated October 29, 2026 (WP Rocket dashboard).
  3. Scroll to the CSS Files section, select Optimize CSS delivery, then choose Remove Unused CSS.
  4. Save your changes and wait while WP Rocket processes your pages in the background.
  5. Visit each key page from your list and check that menus, sliders, forms, and popups still look and work as they should.

WP Rocket processes each page to work out which CSS is actually used, then puts only the relevant rules into an inline CSS block in the page source. That applies to external stylesheets too, according to WP Rocket's knowledge base (Handling external resources).

The feature also applies font-display: swap to the fonts in the resulting used CSS, per WP Rocket documentation (Font display).

If the layout breaks, switch the same setting to Load CSS Asynchronously instead. That option stops CSS from blocking the first paint but does not strip unused rules, so it is a fallback rather than a fix. For the full WP Rocket setup, see the WP Rocket Core Web Vitals configuration guide.

How do you remove unused CSS with Perfmatters?

Turn on Remove Unused CSS under the CSS section of Perfmatters, then pick how the original stylesheets should behave.

  1. Install and activate Perfmatters, then open its settings in the WordPress admin.
  2. Scroll to the CSS section and toggle on Remove Unused CSS.
  3. Choose the stylesheet behavior for the original files: Delay, Async, or Remove.
  4. Turn off CSS combine in any other plugin you run, since Perfmatters warns that combining CSS is a deprecated technique since HTTP/2.
  5. Clear your caches, then check every key page from your list.

The three behaviors work differently, as Perfmatters documents them (Remove unused CSS). Delay is the default: original stylesheets load only after user interaction.

Async loads them without blocking the page, which can cause a brief flash of unstyled content. Remove drops them entirely, which is the most aggressive choice and most likely to need exceptions.

MethodWhat happens to original stylesheetsBest forWatch out
WP Rocket Remove Unused CSSReplaced by inline used CSSHands-off cleanup on most sitesLayout can break on dynamic pages
Perfmatters DelayLoaded on user interactionSafest automatic optionStyles arrive late if a visitor never interacts
Perfmatters AsyncLoaded without blockingAvoiding a flash of missing stylesSlightly higher LCP and FCP than Delay
Perfmatters RemoveDropped entirelyAdvanced users who can add exceptionsMost likely to break interactive parts
Code dequeueWhole file never loadsOne plugin file on pages that never use itNeeds the right handle and priority

Perfmatters stores the used CSS it generates locally in a cache folder under your site, at a path like /wp-content/cache/perfmatters/yourdomain.com/css/, according to its documentation (Remove unused CSS). Run only one unused CSS tool at a time: if Perfmatters handles it, leave the same feature off in your cache plugin.

How do you remove a whole stylesheet with code?

Use wp_dequeue_style() with the stylesheet handle, hooked to wp_enqueue_scripts at a late priority, to stop a stylesheet loading.

WordPress loads stylesheets through handles, and wp_dequeue_style() removes a previously enqueued CSS stylesheet by its handle, according to WordPress Developer Resources (wp_dequeue_style()).

The function has existed since WordPress 3.1.0 (wp_dequeue_style()). Add the code to a child theme or a code snippet plugin, never to a parent theme that updates will overwrite.

add_action( 'wp_enqueue_scripts', 'my_theme_remove_unused_styles', 20 );
function my_theme_remove_unused_styles() {
    if ( ! is_page( 'contact' ) ) {
        wp_dequeue_style( 'contact-form-7' );
    }
}

The example above stops the Contact Form 7 stylesheet loading on every page except the contact page. Find the handle by viewing the page source and looking at the link tag for the stylesheet.

Use a priority above 10, so your code runs after the plugin has enqueued its styles. WordPress Developer Resources shows the same pattern with priority 11 (wp_dequeue_style()).

One limit matters: wp_dequeue_style() cannot dequeue a handle that sits in another stylesheet's dependency list, as WordPress Developer Resources states (wp_dequeue_style()). If your dequeue call does nothing, check whether another asset lists that handle as a dependency, and dequeue the dependent asset instead.

How do you handle CSS that only some pages need?

Load page-specific styles only on the pages that use them, and unload plugin styles from pages where they never appear.

Many plugins load their stylesheet on every page even when only one page uses the feature. A contact form plugin is the classic case: its CSS is needed on the contact page and wasted everywhere else.

The code approach in the previous section solves this with a condition such as is_page(), which limits the dequeue to pages that do not need the file.

If you prefer no code, a plugin that unloads assets per page gives you the same control from the WordPress admin. Open a page in the admin, find the asset manager, and disable the stylesheets that page never uses.

Either way, check the page after each change, since a stylesheet can serve more than one feature.

Splitting CSS by page is the same idea web.dev recommends for large shared bundles. Its resource loading guide says the Coverage tool can show which CSS a page actually uses, and suggests splitting CSS files so different pages load different resources (Optimize resource loading).

What should you do when removing CSS breaks your layout?

Turn the feature off for the broken page, find the missing class in the browser, and add it to the safelist or exclusion list.

  1. Clear all caches first, since a stale cache can look exactly like a broken layout.
  2. Open the broken page and compare it with the staging copy, or with the feature turned off.
  3. Use the browser inspector to find which element lost its styling, and note the class or ID name.
  4. Add that class, ID, or file to the safelist or exclusion list in your plugin, then save and clear the cache again.
  5. Reload the page and check the same element on desktop and on a phone.

WP Rocket provides a CSS Safelist box for filenames, IDs, and classes that must be kept, and Perfmatters lets you add exceptions for stylesheets that must stay.

Dynamic content is the usual cause: a slider, accordion, or popup adds classes with JavaScript after the page loads, so the cleanup tool never saw them in use. Safelist those classes before you enable the feature, not after the layout breaks.

How do you check that it worked?

Re-run PageSpeed Insights on the same pages and confirm the Reduce unused CSS warning is gone or smaller, and that every page still looks right.

  1. Clear your cache plugin, your CDN cache, and your browser cache, so you measure the new files.
  2. Run PageSpeed Insights on each key page and compare the result with the note you made before.
  3. Open Chrome DevTools Coverage again and compare the Unused Bytes column with your earlier numbers.
  4. Click through every menu, slider, popup, and form on each key page.
  5. Check the same pages on a phone, since mobile layouts use different rules.

Lighthouse only lists stylesheets with unused CSS when the potential saving is 2 KiB or more, according to Chrome for Developers (Remove unused CSS).

A warning that disappears means the remaining waste on that page is below that line, not that the file is perfectly clean. If you want a broader speed check after this fix, work through the WordPress speed guide next.

What mistakes should you avoid?

Avoid judging unused CSS from a single page, working on the live site, and running two cleanup tools at once.

  • Deleting rules based on one page's Coverage report, when the same rules are needed on another page, at another screen size, or after a click.
  • Enabling unused CSS removal on a live site without a backup or a staging copy to fall back on.
  • Running two unused CSS tools at once, so each one fights the other and the result is hard to trace.
  • Chasing a zero in the audit: Lighthouse ignores savings under 2 KiB, so a small remaining warning is not worth hours of work.
  • Forgetting dynamic content, such as classes added by JavaScript for sliders, tabs, and popups.
  • Skipping the cache clear after a change, then judging a result that still shows the old files.

Frequently asked questions

Can I remove 100% of unused CSS in WordPress?

No, not in practice. Themes and plugins share stylesheets across pages, and some rules only apply after a click or on another screen size. Aim to shrink the Reduce unused CSS warning and the unused bytes in Coverage, rather than chasing a perfect zero that the tools cannot confirm.

Will removing unused CSS break my site?

It can, usually on pages with sliders, popups, accordions, or forms that add classes with JavaScript after the page loads. Test on a staging copy first, check every interactive part, and keep a safelist or exclusion list for the classes that must stay. A backup lets you restore the site fast if something slips through.

Is unused CSS the same as render-blocking CSS?

No, they are related but different. Render-blocking CSS delays the first paint because the browser must process it before showing content. Unused CSS is any rule the page never uses, whether it blocks rendering or not. Removing unused CSS often fixes render-blocking warnings too, because there is simply less CSS to process.

Do I still need to minify CSS after removing unused CSS?

Yes. Minification is a separate step that strips spaces and comments from the CSS you keep, while unused CSS removal deletes rules you do not need. Keep minification on in your cache or performance plugin after the cleanup, and clear the cache so the new files are served.

How often should I check for unused CSS?

Check after every theme change, plugin install, or redesign, since each of those can add new stylesheets or load old ones on more pages. A quick PageSpeed Insights run on your key pages after a change is enough. If the warning returns, repeat the Coverage check and the cleanup steps.

Does removing unused CSS help SEO?

It helps indirectly. Less CSS means faster rendering, which supports better Core Web Vitals results, and page speed is a factor search engines consider. The CSS itself is not a ranking factor, so treat this as a speed fix with an SEO side effect, not as a direct ranking tactic.

Sources

  1. Remove unused CSS Chrome for Developers
  2. Coverage: Find unused JavaScript and CSS Chrome for Developers
  3. Optimize resource loading web.dev
  4. How to Remove Unused CSS on WordPress WP Rocket
  5. How to automatically remove unused CSS in WordPress Perfmatters
  6. wp_dequeue_style() WordPress Developer Resources
  7. WP Rocket dashboard WP Rocket

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

WPLegible editors

Researched from the primary sources listed above and checked against our editorial rules. About the site · How we test