To remove unused CSS in WordPress, first measure which stylesheets and scripts a page never runs, then unload whole files you do not need before you try to rewrite the leftovers.
Lighthouse flags JavaScript files with more than 20 KiB of unused code, and lists CSS files with at least 2 KiB of potential savings.
Those numbers are leads, not orders. A script that waits for a click looks unused until someone clicks. The safe work is to unload assets page by page, then test every feature that file powers.
⚡ Quick answer
- Best for: site owners who already cache and compress images, and still see “Reduce unused CSS” or “Reduce unused JavaScript” in PageSpeed Insights.
- Skip it if: you have not done the basics yet. Fix hosting, caching and images first, using our guide to speed-optimise a WordPress site.
- Time needed: 1–2 hours for a first pass on the home page and one inner template, including testing.
- Our call: unload whole plugin files on pages that do not use them. Only then consider a “remove unused CSS” generator for leftovers such as the block library.
💡 On this page
- What does unused CSS and JavaScript mean in WordPress?
- How do you measure unused CSS and JavaScript?
- What you need before you start
- How to unload whole files you do not need
- What to do with stylesheets that are only partly used
- Delay, defer and other traps
- How to check it worked, and what breaks
- Frequently Asked Questions
What does unused CSS and JavaScript mean in WordPress?
WordPress prints a CSS or JavaScript file when a theme or plugin “enqueues” it. Many plugins enqueue their assets on every page, even when the form, slider or chat box is not there.
“Unused” then means two different problems, and they need different fixes.
Whole files a page never needs: a contact-form stylesheet on the blog, a slider script on the about page, a page-builder file on a view that does not use that builder.
Partly used files: one stylesheet holds rules for every block or widget, while this page uses five of them. You cannot delete the file without breaking those five.
The Lighthouse unused CSS audit explains why leftover CSS hurts: the browser must download and process external stylesheets before it can paint, and extra rules slow the render tree.
Unused JavaScript competes for bandwidth even when it is not render-blocking. The Lighthouse unused JavaScript audit also notes the cost for mobile visitors on metered data.
Unused CSS often shows up as a slower LCP, and heavy scripts can hurt INP. See how to pass Core Web Vitals in WordPress and how to fix poor INP in WordPress.
The catch: PageSpeed Insights records one load. It does not open your mobile menu, submit a form or start a slider. Treat the report as a shortlist, then confirm each file in the Coverage panel while you use the page.
How do you measure unused CSS and JavaScript?
Start with Chrome’s Coverage panel, not with a plugin toggle. The Chrome DevTools Coverage documentation is the official walkthrough.
- Open the page in a private window, logged out, so the admin bar’s own files stay out of the numbers.
- Open DevTools, press Ctrl+Shift+P (Cmd+Shift+P on a Mac), type
coverage, and choose Show Coverage. - Pick Per function or Per block, then click the reload button in the middle of the panel.
- Scroll the page and use every menu, tab, accordion, form and slider you expect a visitor to use.
- Click Stop instrumenting coverage and show results.
- Sort by Unused Bytes. Write down the largest files and whether they live under
/wp-content/plugins/,/wp-content/themes/or/wp-includes/.

Each row shows the URL, the type (CSS, JavaScript or both), total bytes, unused bytes and a bar: gray did not run, green did. Click a row to see unused lines marked in the Sources panel.
Run PageSpeed Insights on the same URL afterwards if you want a Lighthouse shortlist to compare. The unused CSS opportunity lists stylesheets with at least 2 KiB of potential savings. Unused JavaScript lists files over the 20 KiB unused threshold.

Match each large URL back to a plugin or theme folder, then to a WordPress handle (the name used in wp_enqueue_style or wp_enqueue_script). The handle is what you will dequeue.
Query Monitor, when you are logged in, lists handles, their source URLs and their dependencies on that request. Ignore admin-bar and dashicons in that view; they load because you are logged in.
Common mistake: stopping the recording before you open the mobile menu or a tabbed section. Those files then look unused, you unload them, and the live site breaks the first time a visitor uses that control.
What you need before you start
- A baseline: one PageSpeed Insights or Coverage export for the home page, taken logged out.
- A staging copy or at least a way to undo a code change quickly. Do not start on a busy checkout page.
- Access: a role that can install a plugin or add a code snippet, plus FTP or a file manager if you need to revert.
- A test checklist: forms, menus, sliders, popups, cart and login, on desktop and a real phone.
If the site is still slow before any CSS work, fix caching and TTFB first. Our WordPress cache plugins roundup and the guide to reduce server response time will move the needle more than a dequeue.
Elementor sites should also work through the builder’s own performance settings. The step-by-step on how to speed up an Elementor website covers that layer, including widgets that inject scripts in a site-wide header.
How to unload whole files you do not need
Once you have a handle for a file that is unused on a template, take it out of the queue on those pages only. WordPress core gives you wp_dequeue_style() and wp_dequeue_script() for this.
Run the dequeue late, after plugins have added their files. A priority of 100 on wp_enqueue_scripts is the usual pattern, because most plugins enqueue at the default of 10.
add_action( 'wp_enqueue_scripts', function () {
wp_dequeue_style( 'contact-form-7' );
wp_dequeue_script( 'contact-form-7' );
}, 100 );
Wrap that dequeue in your own page or widget check, so the file still loads wherever the form actually appears.

If you would rather not write PHP, a script manager does the same job with toggles. Perfmatters and Asset CleanUp both let you disable a handle per page, per post type or site-wide except for a short allow list.
Our Perfmatters review covers the Script Manager. Turn on test mode first, so only you see the change, and do not disable a dependency such as jQuery until you have checked what relies on it.
Do this if Coverage shows a plugin file at or near 100% unused on a template, and you have used every feature of that page. That is usually the cheapest win.
Skip it if the file is only partly unused, or if it belongs to WordPress core under /wp-includes/. Core files are a poor first target; you will fight upgrades and break the admin or the editor.
The catch: dequeueing a parent handle also drops scripts that depend on it. If the cart or a slider stops working, put the handle back and inspect the dependency tree.
What to do with stylesheets that are only partly used
Some files will always look messy in Coverage. The combined block library, registered as wp-block-library, holds rules for every core block. A typical post uses a handful of them.
You cannot dequeue that file on a post that still uses those blocks. The same is true of many page-builder and theme bundles: the unused bytes sit in the same file as the used ones.
This is where “Remove Unused CSS” or unique CSS (UCSS) features come in. A cache or performance plugin generates a smaller stylesheet for one URL, holding only the rules that page matched.
WP Rocket’s Remove Unused CSS is one implementation; LiteSpeed Cache’s UCSS is another. Both only handle CSS, not JavaScript, and they need to be regenerated when the page’s HTML changes.
Our WP Rocket review covers that feature set. Use a generator only after whole files are gone, or you will build unique CSS for plugins that should not load at all.
Chrome’s unused CSS documentation also describes a manual path: inline the CSS needed for the first paint, then load the rest later. On WordPress, a well-configured cache plugin is usually less brittle than hand-maintained critical CSS.
For images and offscreen media, unloading CSS will not help much. Use lazy load plugins for that job, and keep this article’s work focused on styles and scripts.
Skip it if the site changes every hour or serves heavily personalised HTML. A unique CSS file goes stale, and a missing rule can collapse a layout until the cache is rebuilt.
Delay, defer and other traps
Several popular toggles make a Lighthouse notice disappear without removing the unused bytes a real visitor still downloads.
Delay JavaScript execution holds a script until a click, scroll or keypress. Lighthouse often never triggers that, so the file drops off the unused-JavaScript list. A visitor still downloads and runs it as soon as they interact.
Delay can still be useful for third-party chat or analytics that should not compete with the first paint. It is not a substitute for unloading a plugin on pages that never use it.
Defer changes when a script runs, not whether it is requested. The file still travels over the network during load, so it can remain on the unused-JavaScript list.
Combine JavaScript or CSS can put the same unused rules into one larger file. That often makes Coverage harder to read and can break the order plugins expect.
On an Elementor site, one Pro widget in a Theme Builder header can load its script on every page. Unique CSS will not fix that. Remove the widget, or replace a heavy addon from our Elementor addons list, then re-measure.
If INP is already poor, delayed third-party scripts can still fire a late interaction cost. Deal with that in the fix poor INP in WordPress guide rather than by stacking more delay rules here.
Common mistake: celebrating a better Lighthouse screenshot after Delay JS, then discovering the live chat or a date picker is what actually cleared the audit. Re-run Coverage after a real interaction and look at the bytes again.
How to check it worked, and what breaks
How to check it worked
- Repeat the Coverage recording on the same URL, logged out, and confirm the unloaded file is gone from the table.
- Re-run PageSpeed Insights and check that the file has left the unused CSS or unused JavaScript list, or that its saved KiB dropped.
- Click every menu, form, slider, popup, cart and login path on desktop and on a phone.
- Watch the browser console for missing script errors after a hard refresh, not only a soft navigation.

What breaks, and how to undo it
A missing stylesheet usually shows as an unstyled form, a broken slider layout or a menu that cannot open. A missing script shows as a control that does nothing, or a console error naming the handle’s file.
Undo is straightforward: remove the dequeue, or re-enable the handle in the script manager, then purge the page cache. If unique CSS looks wrong, delete that URL’s generated file and regenerate it after the layout is healthy again.
If you used a snippet plugin, disable that snippet first, then clear cache. Keep a note of each handle you change so you can reverse one change at a time.
Caching can hide both success and failure. After every change, purge the cache for that URL, then test in a private window. Otherwise you may “fix” or “break” a page you are not actually seeing.
Do this if a checkout, login or form is involved: make the change on staging, place a test order or submission, and only then copy the rule to production.
Frequently Asked Questions
How do I remove unused CSS in WordPress without a plugin?
Measure the page with the Chrome Coverage panel, match each unused file to its WordPress handle, then call wp_dequeue_style() or wp_dequeue_script() on wp_enqueue_scripts at priority 100, only on templates that do not need the file. Test every feature of the page before you leave the rule in place.
Is it safe to delete unused CSS that Lighthouse lists?
Not automatically. Lighthouse records one load and flags files with unused bytes, including code that only runs after a click or scroll. Use the list as a shortlist, confirm each file in Coverage after you use the page, and unload whole files only where you have tested the features they power.
What is the difference between unused CSS and unused JavaScript?
Both waste bytes, but CSS is often render-blocking, so leftover styles can delay first paint. Unused JavaScript may still download in the background and compete for bandwidth, and Lighthouse flags a file when more than 20 KiB of it did not run. Unload whole files for both; unique CSS tools only help with leftover style rules.
Will delaying JavaScript fix the unused JavaScript audit?
It can clear the Lighthouse notice, because the lab test may never click or scroll. A real visitor still downloads and runs the file on first interaction. Delay is reasonable for third-party chat or analytics. It is not a replacement for unloading a plugin on pages that never use it.
Should I dequeue the WordPress block library stylesheet?
Usually no, if the page still uses core blocks. wp-block-library holds rules for every core block, so Coverage will always show unused bytes on a typical post. Dequeuing it can break those blocks. Trim plugin files first, then consider a unique CSS generator for the leftovers.
Which plugin is best for removing unused CSS in WordPress?
There is no single best tool. A script manager (such as Perfmatters or Asset CleanUp) is the right fit for unloading whole files per page. A “remove unused CSS” or UCSS feature in a cache plugin is the right fit for partly used stylesheets, after the whole-file pass. Pick based on which problem you still have.
Why is unused CSS still high on my Elementor site?
Elementor and many addons enqueue assets globally, especially when a widget sits in a Theme Builder header or footer. Unique CSS can shrink the stylesheet, but a heavy widget still ships its script on every URL. Remove or replace those site-wide widgets, then re-measure Coverage.
Does removing unused CSS improve Core Web Vitals?
It can, especially when a render-blocking stylesheet shrinks or disappears and LCP improves. The effect on INP depends on whether you also unload or delay heavy JavaScript. Measure field data after the change. Unused-CSS cleanup is one step in a Core Web Vitals pass, not the whole job.
Unload the plugin files a template never needs, then re-measure. That is the part of “remove unused CSS” that actually cuts requests.
Leave unique CSS generators for the leftover bundle, and do not treat Delay JavaScript as proof that the bytes are gone.
If the page is still heavy after a clean Coverage table, go back to caching, images and server response; those guides will take you further than another dequeue.
Last updated November 2026.




