Start JavaScript coverage before the navigation or interaction you want to measure, then stop it to retrieve the collected script entries:
await page.coverage.startJSCoverage();
await page.goto('https://example.com');
// Exercise the routes and interactions you want to measure.
const jsCoverage = await page.coverage.stopJSCoverage();
The returned entries include script text and usage ranges. What they show depends on the pages and actions exercised during that collection.
Start coverage before the activity you want to measure
Create a page, start coverage, navigate, and exercise the relevant parts of the site. Stop coverage before leaving the page if you need to preserve that page’s results.
const page = await browser.newPage();
await page.coverage.startJSCoverage();
await page.goto('https://example.com');
// Exercise representative routes and interactions here.
const jsCoverage = await page.coverage.stopJSCoverage();
startJSCoverage() resolves when collection has started. stopJSCoverage() resolves with an array of JavaScript coverage entries. The official Puppeteer API example calculates a byte-use ratio from each entry’s script text and ranges:
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
let totalBytes = 0;
let usedBytes = 0;
for (const entry of jsCoverage) {
totalBytes += entry.text.length;
for (const range of entry.ranges) {
usedBytes += range.end - range.start - 1;
}
}
console.log(`Bytes used: ${(usedBytes / totalBytes) * 100}%`);
This follows the calculation in the Puppeteer Coverage class documentation. Treat the result as a percentage of the scripts covered in this run, not as a universal measure of how much of the whole application is used. Include representative routes and interactions before using it to guide cleanup.
Choose coverage options deliberately
The Puppeteer JSCoverageOptions reference lists these defaults. It labels itself version 25.12.0; the Coverage class page is labeled version 25.10.0. These are documentation versions, not a guarantee that they match your installed package, so check the documentation for your pinned Puppeteer version when compatibility matters.
| Option | Documented default | What it changes |
|---|---|---|
resetOnNavigation |
true |
Coverage resets on navigation by default. Setting it to false does not guarantee prior-page data survives; Chrome may discard the previous page’s JavaScript execution environment. |
reportAnonymousScripts |
false |
Includes anonymous scripts, such as dynamically created code from eval or new Function, when enabled. Puppeteer reports them under a debugger://VM URL unless the script includes a //# sourceURL comment. |
includeRawScriptCoverage |
false |
Controls whether raw script coverage is included in the entries. |
useBlockCoverage |
true |
Controls block-level versus function-level coverage collection. |
Set options when starting collection if the defaults do not match what you need. For example, to include dynamically created anonymous scripts:
Rank #2
await page.coverage.startJSCoverage({ reportAnonymousScripts: true });
The Puppeteer API documentation notes that JavaScript Coverage does not include anonymous scripts by default.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Handle navigation as separate collections
Coverage can reset when a page navigates, and disabling resetOnNavigation is not a reliable way to retain all data: Chrome may discard the prior page’s execution environment and its coverage. For a multi-page test, stop coverage before navigating away, start a new collection on the next page, and merge the reports in your own reporting workflow.
Starting early matters when initial page execution is in scope. The Chrome DevTools Protocol’s Profiler reference cautions that JavaScript executed before precise coverage is enabled may be incomplete. It also notes that enabling precise coverage prevents optimized code and resets execution counters. Start collection before navigation rather than after the page has already loaded.
Use representative actions, not just a page load
Coverage records execution during the captured session. A page load alone will not exercise code behind menus, dialogs, tabs, forms, or later routes. Build the automation around the behaviors relevant to your question, and interpret unused ranges only in light of those actions.
- For initial-load coverage, start before
page.goto(). - For interaction coverage, perform the interactions before calling
stopJSCoverage(). - For route-by-route results, collect each page separately when navigation could reset or discard data.
When to use Chrome DevTools instead
Use Puppeteer when you need a scripted, repeatable run that can be integrated into automation. For exploratory inspection, Chrome DevTools’ Coverage panel records JavaScript and CSS as you reload and interact with a page, and shows the analyzed resources and code usage. The Chrome DevTools Coverage guide describes unused-code inspection as a starting point; deciding whether to refactor depends on the application’s technology stack.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Troubleshoot incomplete or unexpected results
Coverage is empty or misses initial scripts
Check that startJSCoverage() completed before the navigation or script execution you intended to capture. The Chrome DevTools Protocol warns that code executed before precise coverage is enabled may be incomplete.
Rank #4
Anonymous scripts do not appear
Anonymous scripts are excluded by default. Start coverage with { reportAnonymousScripts: true } when dynamically created code matters. Such entries use a debugger://VM URL unless the script supplies a //# sourceURL comment.
Earlier pages are missing after navigation
Coverage resets on navigation by default, and setting resetOnNavigation: false cannot ensure Chrome retains a discarded execution environment. Stop coverage before leaving each page, start a fresh collection on the next page, and combine the resulting reports.
The percentage seems too high or too low
The calculation describes only the scripts and ranges captured in that run. Add the routes and interactions that represent actual use before treating the figure as evidence for code removal.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Best Value
- Used Book in Good Condition
Or skip the browser setup
If your goal is a website screenshot rather than JavaScript execution coverage, ScreenshotNeo can return a screenshot or PDF from one GET request. It does not collect Puppeteer coverage data; it is an alternative for capturing rendered pages without setting up browser automation.
ScreenshotNeo API documentation
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
- Cookie and consent banners are accepted before capture, and 60+ known consent platforms, newsletter popups, and chat widgets are removed; each step can be turned off.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing; response headers identify the page verdict and whether the request was billed.
- An MCP server provides
take_screenshot,get_page_info, andcapture_pdftools for AI agents and MCP clients. - The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Every feature is available on every plan.
Sign up free for 1,000 screenshots a month, with no card required.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




