CSSHOUND · UNUSED CSS FINDER · RUST + WEBASSEMBLY · RUNS IN YOUR BROWSER

Which of this page's CSS rules does it never use?

Paste a whole HTML page, or a stylesheet with the markup and scripts that use it. csshound judges every rule by PurgeCSS's rules and lists the ones nothing in the content names, with the bytes each one costs. Pages copy stylesheets from each other; this shows what each page carries for nothing.

Nothing is uploaded. What you paste is handed to a WebAssembly module from this site; the page makes no network requests of its own after it loads.

1. Paste a page, or CSS and content

How it decides

It can call a rule unused that a visitor does see: a class name your code builds with no literal prefix, markup fetched at run time, or a class set by a script from another site. Check before deleting.

Run it over a whole site

The CLI reads every HTML page under a folder, takes each page's <style> blocks and linked local stylesheets, and judges them against the page, the local scripts it loads and every module those scripts import.

git clone --depth 1 --filter=blob:none --sparse https://github.com/duncan-haywood/oss-monorepo
cd oss-monorepo && git sparse-checkout set ventures/csshound
cargo install --path ventures/csshound
csshound site/            # summary and the worst pages
csshound --dead site/     # every unused rule, page:offset: selector
csshound --fail site/     # CI gate: exit 1 if anything is unused

Measured on this repository

On 3,915 HTML pages (99,479 rules, 8,101,928 bytes of CSS), on a 4-core container: 0.50 to 0.52 s and 18 to 21 MB. It found 8,815 rules (644,192 bytes, 8.0% of the CSS) that nothing on their page uses. With PurgeCSS's input, which does not follow imports, the count was 13,412: following imports removes a third of the findings. Run against PurgeCSS 9.1.0 itself on 3,923 pages with the same input, the two rejected the same 15,632 selectors, with no difference either way. PurgeCSS took 4.6 to 4.9 s and 123 MB; csshound 0.31 to 0.36 s (1.1 s on one thread) and 10 MB. The benchmark has the commands to repeat it.

Questions

Is my code uploaded?

No. What you paste is handed to a WebAssembly module loaded from this site and judged in this tab. The page makes no network requests of its own after it loads.

How does it decide a rule is unused?

The same way PurgeCSS does by default: the markup and scripts are cut into words, and a selector is unused when one of its classes, ids, tags or attributes is not one of those words. Pseudo-classes and combinators never count against a selector, and rules inside @keyframes are left alone.

Can it be wrong?

Yes, in the direction of calling something unused that a visitor does see: a class name your code builds with no literal prefix, markup fetched at run time, or a class set by a script from another site. It keeps classes built from a literal prefix plus a value, such as "tier-" + level. Check a finding before deleting the rule.

How is this different from PurgeCSS?

It uses PurgeCSS's rules but works page by page over a whole folder, follows the imports of each page's scripts, and reports instead of rewriting files. Given the same input, it rejects exactly what PurgeCSS 9.1.0 rejects: 15,632 selectors on 3,923 pages, no difference either way.