Chrome Coverage may mark a JavaScript function unused after load, then show it as used after somebody opens a menu or expands a panel. The report tells you which parts ran during that recording.
Compare two fresh runs on the same page before changing when a script loads.
Record a load-only baseline
Open the exact page in Chrome DevTools. Use the Command Menu to find Show Coverage. Start Coverage with the reload button in the panel so it measures the load. Wait for the same initial state you will use in both runs, then stop recording without interacting with the page.
Open one JavaScript entry. Record the exact file URL and the section you need to inspect. Use the unused percentage to locate a candidate. The source view identifies the recorded and unrecorded portions, which you can match to a feature.
Repeat with one user action
- Start a fresh recording with a reload. Keep the build, route, viewport and test state the same. Start from the same panel state so the interaction is the sole intentional change.
- Perform one action, such as opening the pickup details on a product page. Keep the recording active until the action finishes.
- Stop the recording and open the same file again. Compare the same source section and record which action changed its coverage.
We ran that comparison in Chrome on an offline fixture with a See pickup details button. Chrome’s JavaScript Coverage API recorded setup in both runs. The handler that reveals the details ran zero times after load and once after the click.
| Recording | Script setup | Pickup function executions | What appeared |
|---|---|---|---|
| Load only | Ran | 0 | Pickup panel hidden. |
| Load and one click | Ran | 1 | Pickup panel visible. |
Decide whether the result warrants a change
The load-only recording would have missed an active feature. A real bundle can also contain code needed on another route, device or customer state. Check the interactions or routes that plausibly use it before removing anything.
If a file is used only after an action, investigate whether to defer some code without making the first interaction slower. Check loading and the first interaction after each change. Include repeat visits, alternate breakpoints or customer states if they can run the same code. The JavaScript SEO guide explains why important page content should be available without requiring a click. The INP diagnosis guide helps if the first interaction gets slower.
Frequently asked questions
What does unused code mean in Chrome Coverage?
It means the recording did not observe that code being used. The same code may run in another recording if you follow a different path.
Can Coverage record clicks after page load?
Yes. Keep the recorder running, make one interaction, then stop it and inspect the same file again.
Can I delete everything marked unused?
First check which pages and states need it. A short recording identifies candidates to investigate. Repeat representative journeys before any removal.

