Developer and Text Tools

How to Find Unused CSS and JavaScript with Coverage Data

Export coverage from Chrome DevTools, merge several pages, see unused bytes per file and list unused selectors before trimming CSS and JS bundles.

Saizul Amin
Saizul Amin3 Nov 2026 · 3 min read
How to Find Unused CSS and JavaScript with Coverage Data

How to Find Unused CSS and JavaScript with Coverage Data

Lighthouse often reports "reduce unused CSS" and "reduce unused JavaScript" with impressive numbers, and teams are tempted to start deleting. That is risky. Code unused on one page is often essential on another, or only runs when someone opens a menu. Coverage data is the right tool for the job, as long as you collect it carefully and read it across pages.

What coverage measures

Chrome's Coverage panel records which byte ranges of every stylesheet and script were used while you interacted with the page. For CSS, a rule counts as used if it matched an element at some point. For JavaScript, a function counts as used if it ran. Everything else is reported as unused. The panel can export the data as JSON, including each file's full text and its used ranges.

Recording useful data

Open DevTools, run the Show Coverage command, and press the reload button inside the panel. Then use the page: scroll to the bottom, open menus and dialogs, switch tabs, submit a form with an error, and resize the window so the mobile and desktop rules both apply. Export the result. Repeat for each important template, such as the home page, a category, a product, the cart and an article.

Reading the results

Open all the exports in the CSS and JS Coverage Analyzer. The tool merges ranges for the same file across pages, so a byte counts as used if any page used it. The file table shows total, used and unused size for each file, sorted with the biggest waste first. Hide entries you do not control, such as browser extension scripts that sometimes appear in the export.

Click a file to see its code with used parts in green and unused parts in red. For stylesheets, the tool also lists every top-level rule that never matched. Those lists are where to start: rules for retired features, old campaigns and components that no longer exist are common.

Turning findings into work

Each file has a plan menu. A shared stylesheet with a lot of unused rules is a candidate for purging with a build tool that removes selectors not found in your templates. A large script used only on checkout should be split into its own bundle and loaded there. A widget script that runs only after a click can be loaded on demand. A file no page uses at all can be removed, after checking with search across the code base. Export the table with your decisions as a CSV work list.

Critical CSS

The Used CSS tab joins the used parts of every stylesheet. It is a helpful starting point for critical CSS, the small set of rules inlined in the head so the first screen renders without waiting for the full stylesheet. Review it before use: states you did not trigger, such as hover and error styles, will be missing, and rule order affects the cascade.

Caution

Unused is a measurement of one session, not a verdict. Code for rare paths, logged-in states, other languages and older browsers will show as unused unless you exercised it. Make changes in small steps, test each template after each change, and keep monitoring errors after release. Done that way, coverage-led cleanups routinely cut stylesheets by half and remove hundreds of kilobytes from bundles without breaking anything.

A realistic target

Few sites reach zero unused code, and they do not need to. A good first goal is to stop sending each page the code of every other page: split bundles by route, purge dead CSS, and load rare features on demand. Measure the transfer size before and after, and track it in your performance budget.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages