Start CSS coverage before the navigation or interactions you want to measure, then call page.coverage.stopCSSCoverage() to retrieve stylesheet entries and their used ranges. Exercise relevant page states during the run: coverage describes what that run used, not everything an application might use.
Collect CSS coverage in Puppeteer
This runnable example starts collection before loading the page, exercises an example interaction, then reports covered and total stylesheet text lengths. Replace the example URL and interaction with the page and states you need to measure.
As an Amazon Associate I earn from qualifying purchases.
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.coverage.startCSSCoverage();
await page.goto('https://example.com');
// Exercise relevant states, such as menus, tabs, and dialogs.
// Example: await page.click('[aria-expanded="false"]');
const cssCoverage = await page.coverage.stopCSSCoverage();
for (const entry of cssCoverage) {
const usedBytes = entry.ranges.reduce(
(sum, range) => sum + range.end - range.start - 1,
0,
);
const totalBytes = entry.text.length;
const usedPercent = totalBytes
? (usedBytes / totalBytes) * 100
: 0;
console.log({
url: entry.url,
usedBytes,
totalBytes,
usedPercent: `${usedPercent.toFixed(1)}%`,
});
}
} finally {
await browser.close();
}
The Puppeteer coverage API documents startCSSCoverage() and stopCSSCoverage(), and its example calculates used bytes by summing end - start - 1 for each range. See the Puppeteer Coverage API and Puppeteer coverage guide.
Recommended Free Tools
Choose what the run should measure
Start before the relevant events
Call startCSSCoverage() before navigating or interacting. If you begin after a page has loaded, the earlier activity is outside the collection window. Stop only after the page has reached the states whose styles you want included.
#1 Best Overall
Exercise interactions, not just initial load
A page that loads without opening its menu, switching tabs, or showing a dialog cannot establish whether those states use CSS. Include the interactions relevant to your use case before stopping coverage. This is a run-specific measurement, not proof that uncovered styles are universally unused.
Plan around navigation resets
Puppeteer documents resetOnNavigation as true by default. Navigation therefore affects the collection scope. Check the option and configure it deliberately if your run includes navigation and you need coverage behavior across that boundary. The API reference documents the option and its default: Puppeteer Coverage API.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Read the coverage entries
Each CSS coverage entry exposes a stylesheet url, its source text, and ranges with start and end positions. Use the URL to identify the stylesheet, the text as the basis for total length, and the ranges to determine what the run covered. See CoverageEntry.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →The example sums each range’s length using Puppeteer’s documented expression, then divides the result by entry.text.length for a simple percentage. Treat the output as an indicator for this particular run: an unvisited page state may still need the styles that appear unused in the report.
Rank #3
Know what CSS coverage can omit
Puppeteer states that CSS coverage does not include dynamically injected style tags that lack sourceURLs. If an application creates styles at runtime this way, the returned coverage may not represent them. See the caveat in the Puppeteer Coverage API.
Chrome’s Coverage guidance also frames coverage as an activity that begins with a reload and continues while you interact with the page. That supports the practical workflow here: record the states you care about during the run rather than inferring usage from the initial render alone. See Chrome DevTools: Find unused JavaScript and CSS.
Rank #4
- 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
Or skip the browser setup
If you need screenshots rather than stylesheet-use ranges, ScreenshotNeo provides a website screenshot API; it does not replace Puppeteer’s CSS coverage API. One GET request returns an image or PDF. For example:
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 →curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation. Cookie and consent banners, newsletter popups, and chat widgets are removed before the shot; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.
Quick Recap
Best Value
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.




