Unused CSS Remover
An unused CSS remover deletes the style rules no element on your pages uses, so the browser downloads and parses less CSS before it can show the page. Add your CSS and your pages (paste them, upload files, load URLs or capture a live page), and the tool tests every selector against them. The example below removes 6 unused selectors and shrinks the stylesheet by 42%.
Advertisement
How to remove unused CSS
- Add your CSS: paste it, upload files, or let the tool load the stylesheets of the pages you add.
- Add every type of page your CSS serves: home, article, product, category, search, contact. A rule used only on one page type is removed if that page is missing.
- Add what JavaScript changes: capture pages with menus and popups open, add the scripts that add classes, or keep the JavaScript states safelist on.
- Check the report, copy or download the cleaned CSS, and test it on a copy of your site before replacing the original.
Exact or keyword matching?
| Mode | How it decides | Best for |
|---|---|---|
| Exact | Builds each page like a browser and runs every selector with querySelector. States the page cannot show by itself (:hover, :focus, ::before, :checked) are ignored while matching, so .btn:hover stays whenever .btn exists. Selectors this browser cannot parse are kept. | Finished HTML pages and captures. Removes the most. |
| Keyword | Keeps a selector when every class, id and tag name in it appears anywhere in your pages or scripts, as PurgeCSS does. Structure such as .a > .b is not checked. | Templates, PHP or Blogger theme code and pages built by JavaScript. Safest. |
In exact mode, class names that appear in the JavaScript you add also count as used, so styles for states that scripts switch on are kept.
Tested on Bootstrap 5.3.3
A test page with a navbar, cards, an alert, a list group, a table, pagination, form controls, buttons and a spinner, cleaned against the full bootstrap.css with the default options. Each result was rendered next to the original at 390 px and 1280 px wide and compared pixel by pixel.
| Version | Size | Gzip | Smaller | Renders the same |
|---|---|---|---|---|
| Original | 281,043 | 33,308 | – | – |
| Exact mode | 34,031 | 6,963 | 87.9% | Yes |
| Keyword mode | 35,602 | 7,203 | 87.3% | Yes |
Both modes kept the styles Bootstrap's JavaScript switches on for elements that exist on the page, such as .form-control.is-invalid and .navbar-nav .nav-link.show, and removed those for components the page does not have, such as dropdowns and modals.
What else it removes, and what it never touches
- Selector lists: in
.btn-danger, .alert-danger { … }only the unused names are removed; the rule stays if one is used. - @media, @supports and @container blocks are cleaned inside and dropped when nothing is left.
- @keyframes are removed when no remaining rule names them in
animation. - @font-face rules are removed when no remaining rule uses that font family, which also stops the browser downloading the font.
- CSS variables (optional) are removed when nothing reads them with
var(), in the CSS, inline styles or scripts you add. - Always kept:
*,html,body,:root,::selection, scrollbar styles,@import,@layerorder,@property,@page, nested rules and licence comments.
Advertisement
Removing unused CSS from a Blogger theme
- Back up the theme: Theme → ⋮ → Backup.
- Capture each page type with the bookmarklet: home page, a post, a static page, a label page (
/search/label/…) and a search result (/search?q=…). Open the mobile menu and any popups before capturing. Blogger blogs block other sites from reading them, so URL loading needs the capture instead. - Use the theme's own CSS: in Edit HTML, copy the CSS inside
<b:skin><![CDATA[ … ]]>and paste it as the stylesheet, replacing the captured inline CSS. That keeps Theme Designer variables such as$(body.text.color)instead of their current values. - Turn on the Blogger widgets safelist if you sometimes add gadgets that are not on the captured pages.
- Paste back: keep the
Variable definitionscomment block at the top of<b:skin>exactly as it was, and paste the cleaned CSS below it.
Blogger also loads its own widget stylesheet. With b:css='false' on the <html> tag it is not loaded, but then every widget needs styles in your theme, so only change it if your theme was built for that.
WordPress
Clean your theme or child theme stylesheet, with pages captured for each template (front page, single post, page, archive, search, 404, and WooCommerce pages if you use it). Turn on the WordPress safelist so block-editor classes such as alignwide and has-text-align-center stay. Plugin stylesheets are best handled by a performance plugin's "remove unused CSS" feature, because they change with every plugin update.
This tool, Chrome Coverage and PurgeCSS
| Method | Gives you | Limit |
|---|---|---|
| This tool | A cleaned stylesheet for many pages at once, with a report and safelists. | Only knows the pages and scripts you add. |
| Chrome DevTools Coverage | Used and unused bytes for one page as you click through it. | Shows unused code but does not write a cleaned file. |
| PurgeCSS in a build | Automatic cleaning on every build of a code project. | Needs Node.js and a build step; not for Blogger or theme editors. |
Tip: after replacing your CSS, check "Reduce unused CSS" in PageSpeed Insights. Then minify the result with the CSS Minifier if you chose formatted output.
Frequently asked questions
What is unused CSS?
Unused CSS is any style rule whose selector matches no element on your pages, such as styles for a slider you removed or the parts of a framework like Bootstrap you never use. The browser still downloads and parses it before it can show the page, so unused CSS slows down rendering without changing how anything looks.
How do I remove unused CSS?
Paste your CSS and the HTML of your pages into this tool, or load the pages by URL. It tests every selector against the pages, removes the ones that match nothing, and gives you a cleaned stylesheet and a report of what was removed. Test the cleaned CSS on a copy of your site before replacing the original.
Does removing unused CSS improve Core Web Vitals?
Usually, yes. CSS blocks rendering, so a smaller stylesheet lets the browser paint sooner, which improves First Contentful Paint and Largest Contentful Paint, especially on mobile. Lighthouse reports it as Reduce unused CSS. The gain is largest when a framework or theme ships far more CSS than a page uses.
Why did it remove styles for my menu, slider or popup?
Those classes are often added by JavaScript after the page loads, so they are not in the page HTML. Use the capture bookmarklet after opening the menu or popup, add the JavaScript files that add the classes, turn on the JavaScript states safelist, or add the class names to the safelist yourself.
What is the difference between exact and keyword matching?
Exact matching builds each page like a browser and tests every selector on it, so it removes the most CSS but needs every page type you use. Keyword matching keeps a selector whenever its class, id and tag names appear anywhere in your pages or scripts, like PurgeCSS. It keeps more CSS but is safer for templates and sites that build HTML with JavaScript.
Can I remove unused CSS from a Blogger theme?
Yes. Capture your home page, a post, a static page, a label page and a search results page with the bookmarklet, then paste the CSS from inside b:skin in your theme as the stylesheet. Keep the Variable definitions comment at the top of b:skin separately, paste it back above the cleaned CSS, and keep a backup of the theme.
Is my code uploaded?
No. Pages and stylesheets are compared in your browser, and URLs are fetched by your own browser too. If a site blocks that, the tool may use a read-only proxy that fetches only the public page you asked for, or you can capture the page with the bookmarklet instead.
What is the difference between unused CSS and critical CSS?
Removing unused CSS deletes styles no page needs. Critical CSS is the small part of the remaining CSS needed to show the first screen, inlined in the page so it can render before the full stylesheet loads. Remove unused CSS first, then extract critical CSS from what is left.
Share this unused CSS remover
Advertisement