October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Puppeteer CSSCoverageOptions: Configure CSS Coverage

Set Puppeteer’s resetOnNavigation option to control whether CSS coverage resets on navigation, then collect and interpret the returned entries with their documented limitation in mind.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To keep Puppeteer’s CSS coverage collection from resetting on each navigation, pass { resetOnNavigation: false } to page.coverage.startCSSCoverage(). The documented default is true, which resets coverage on each navigation. The option controls that reset behavior; it does not establish a broader guarantee that coverage data will persist through every browser or page lifecycle event.

What CSSCoverageOptions configures

In Puppeteer’s 25.10.0 API reference, CSSCoverageOptions is the optional configuration object accepted by page.coverage.startCSSCoverage(options?). The reference lists one property: resetOnNavigation?: boolean.

Setting Documented behavior Use it when
true (default) Coverage resets on each navigation. You want navigation to begin a fresh coverage collection window.
false Coverage does not reset on every navigation. You want to avoid a reset on navigation during the collection window.

These descriptions reflect the Puppeteer 25.10.0 API documentation; check the API reference for the Puppeteer version installed in your project if behavior or types differ.

Configure CSS coverage across navigation

Start coverage before navigating, then stop it after the pages or interactions you want to include. startCSSCoverage() resolves to void; the entries are returned by stopCSSCoverage().

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.coverage.startCSSCoverage({ resetOnNavigation: false });

await page.goto('https://example.com');
// Navigate to other pages or perform interactions to include in the collection.

const cssCoverage = await page.coverage.stopCSSCoverage();
console.log(cssCoverage);

Omit the options object, or set resetOnNavigation: true, when each navigation should reset the collection. Setting it to false asks Puppeteer not to reset coverage on every navigation; it should not be read as a promise about data surviving every possible browser lifecycle event.

Estimate used CSS bytes from the returned entries

Puppeteer’s coverage example estimates the share of reported source text covered by ranges. Applied to CSS entries alone, this gives a byte-range estimate for the data returned by the coverage API, not a complete measurement of every style that affected the page.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
const totalBytes = cssCoverage.reduce(
  (sum, entry) => sum + entry.text.length,
  0,
);

const usedBytes = cssCoverage.reduce(
  (sum, entry) => sum + entry.ranges.reduce(
    (entrySum, range) => entrySum + range.end - range.start - 1,
    0,
  ),
  0,
);

const usedPercent = totalBytes === 0 ? 0 : (usedBytes / totalBytes) * 100;
console.log({ totalBytes, usedBytes, usedPercent });

The calculation sums each entry’s text length as total bytes and the reported covered-range lengths as used bytes. Treat the percentage as an estimate based on those coverage entries, not as proof that all runtime CSS was observed.

Coverage’s CSS blind spot

Puppeteer documents that CSS Coverage does not include dynamically injected style tags without sourceURLs. Those styles therefore will not appear in the returned coverage entries. Account for that limitation before using a report to remove supposedly unused CSS; in particular, the report is not a complete accounting of every runtime style.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshooting

  • The report is empty or shorter than expected: Confirm that startCSSCoverage() ran before the page activity you intend to measure and that stopCSSCoverage() ran after it. Check whether the default reset-on-navigation behavior is appropriate for your collection window.
  • Styles visible in the page are missing: Dynamically injected style tags without sourceURLs are an explicitly documented omission. The returned entries cannot be treated as a full inventory of those styles.
  • You need a new report after each page load: Use the default behavior, resetOnNavigation: true, so navigation resets coverage.

Or skip the browser setup

ScreenshotNeo is a website screenshot API, not a CSS coverage collector, so it does not replace Puppeteer’s CSS coverage report. If you also need a screenshot of a page, its one-call API can capture it:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo API documentation. It removes cookie banners, popups and chat widgets before the shot; bot checks, blank pages and failed loads are never billed. Its MCP server lets AI agents take screenshots, and 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Can I use the same options object to configure JavaScript coverage?

No. CSSCoverageOptions applies to CSS coverage started through page.coverage.startCSSCoverage(); consult the JavaScript coverage API for its own options.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Can Puppeteer export coverage in an Istanbul-compatible format?

Puppeteer points to puppeteer-to-istanbul as a tool for producing output consumable by Istanbul.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.