# JS coverage

> JS coverage is the share of a page's downloaded JavaScript that actually runs on the page. Unused code still costs download and parsing time.

- **Check ID:** P10
- **Area:** [Performance](https://be1st.ai/glossary/performance)
- **Tool:** [SEO + Security + Performance](https://be1st.ai/tools/ssp-audit)
- **Page:** https://be1st.ai/glossary/performance/js-coverage

## Why it matters

JavaScript is the most expensive resource to process: it must be downloaded, parsed, compiled, and executed. Unused JS wastes all of these resources. Lighthouse flags every JS file with more than 20 KiB of unused code. Tree shaking and code splitting are key optimizations.

## In practice

Webpack bundle analyzer often reveals that 60% of JavaScript code is unused. Next.js uses automatic code splitting: each page loads only the JS it needs. If your website loads 2 MB of JavaScript but uses only 400 KB, mobile devices spend seconds parsing unnecessary code.

## How be1st checks it

Measures the percentage of unused JavaScript code on the page. The ideal value is less than 50% unused JS. Unused JavaScript unnecessarily increases file sizes, slows down downloads, parsing, and compilation, which directly affects Time to Interactive.

[SEO + Security + Performance](https://be1st.ai/tools/ssp-audit), Performance tab.

Every check ends as: Pass, Warning, Fail.

## Sources

- [Remove unused JavaScript](https://developer.chrome.com/docs/lighthouse/performance/unused-javascript) (Chrome for Developers)
- [Remove unused code](https://web.dev/articles/remove-unused-code) (web.dev)
- [Coverage: Find unused JavaScript and CSS](https://developer.chrome.com/docs/devtools/coverage) (Chrome DevTools)

## Related terms

- [Response time (TTFB)](https://be1st.ai/glossary/performance/response-time-ttfb): Time to First Byte (TTFB) is the time from sending a request to receiving the first byte of the server's answer. It shows how fast the server and the network respond.
- [HTML size (performance)](https://be1st.ai/glossary/performance/html-size): HTML size is the weight of a page's HTML document in kilobytes. The browser has to download and parse all of it before it can show the page.
- [External resources](https://be1st.ai/glossary/performance/external-resources): External resources are the separate script and stylesheet files a page loads. Each one is another download that can delay rendering.
- [Inline CSS](https://be1st.ai/glossary/performance/inline-css): Inline CSS is styling written directly in the HTML, in `<style>` blocks or style attributes, instead of in a separate stylesheet file.
- [Inline JS](https://be1st.ai/glossary/performance/inline-js): Inline JavaScript is code written directly in the HTML inside `<script>` tags, instead of in a separate file the browser can cache.
- [Image optimization](https://be1st.ai/glossary/performance/image-optimization): Image optimization means serving images in the right size and format and loading the ones below the fold only when they are needed.
