npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

css-scan

v2.0.0

Published

A CLI tool to scan and export used and unused CSS from web pages.

Readme

CSS Scan

Version License Open PRs Issues

A CLI tool to scan websites and identify unused CSS. Uses Playwright to simulate real browser rendering across multiple viewport sizes and pages, providing accurate, merged CSS coverage analysis.

Features

  • Multi-Page Scanning: Crawl internal links to generate a global "used CSS" file for your entire site.
  • Viewport Coverage: Scans across desktop, tablet, and mobile viewports for every page.
  • Smart Merging: automatically combines usage data from multiple pages to prevent deleting CSS used on one page but not another.
  • Exports: Generates used.css and unused.css files.
  • Interactive UI: Terminal interface with real-time crawling progress.
  • Prettier: Automatically formats the output CSS.

Requirements

  • Node.js 18+
  • Playwright (installed automatically with dependencies)

Installation

npm install -g css-scan

Or run directly with npx:

npx css-scan

Usage

Interactive Mode

css-scan

You will be prompted to enter a URL. By default, this runs a single-page scan.

CLI Arguments

You can pass arguments to skip the interactive prompt and enable advanced crawling.

| Flag | Alias | Description | Default | | --- | --- | --- | --- | | --url | -u | The starting URL to scan | null | | --depth | -d | How many levels of links to crawl | 0 (Single Page) | | --max-pages | -m | Maximum number of pages to scan | 1 |

Examples

Scan a single page:

css-scan -u https://example.com

Scan a page and its immediate children (Depth 1), up to 5 pages total:

css-scan -u https://example.com --depth 1 --max-pages 5

Deep crawl (Depth 2) of a documentation site:

css-scan --url https://docs.example.com -d 2 -m 20

Output

The tool generates two files in your current working directory:

| File | Description | | --- | --- | | used.css | Combined CSS rules used across all scanned pages | | unused.css | CSS rules that were not used on any scanned page |

Console output includes:

  • Number of pages scanned
  • Total Bytes Processed
  • Used vs. Unused Bytes
  • Final Unused Percentage

Viewport Coverage

CSS coverage is collected across the following viewport configurations for every page scanned:

  • Desktop: 1920x1080
  • Tablet: 768x1024
  • Mobile: 375x667

This ensures media queries and responsive styles are properly evaluated.

How It Works

  1. Launch: Starts a headless Chromium browser via Playwright.
  2. Crawl: Visits the target URL. If --depth is > 0, it extracts internal links and adds them to a queue.
  3. Scan: For each page in the queue (up to --max-pages):
  • Cycles through Desktop, Tablet, and Mobile viewports.
  • Scrolls to trigger lazy-loaded elements.
  • Captures CSS coverage data.
  1. Merge: Intelligently merges CSS ranges. If a class is used on Page A but not Page B, it is marked as Used.
  2. Write: Outputs the final, formatted CSS files to disk.

Development

# Install dependencies
npm install

# Build
npm run build

# Run locally
npm start

License

MIT