OSS TanbouSign in with GitHub

scan content files and keep only selectors that are actually referenced

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
8,050
Primary language
TypeScript
License
MIT
Repository last updated
Aug 20, 2026
On this page

Overview

PurgeCSS scans HTML, JavaScript, templates, and other content, compares extracted tokens with CSS selectors, and removes unused rules. It supports CLI, programmatic, PostCSS, Webpack, and other integrations.

Features and best fit

Based on official documentation; not hands-on tested · Content checked:

Key features

Compare content tokens with CSS and remove unused selectors

It scans content files and removes stylesheet selectors that are not represented in the extracted usage set.

Sources: [1][2]

Protect dynamic selectors with safelists and custom extractors

Safelists and extractor APIs prevent false removals when static content scanning cannot represent framework or runtime-generated class names.

Sources: [1][3]

Choose CLI, PostCSS, Webpack, and other integrations

PurgeCSS can run standalone or inside common frontend build pipelines through dedicated packages and plugins.

Sources: [1]

Best fit

Fits projects with large shared or utility CSS where only a subset is used in production

It is especially useful when deployed CSS contains many selectors that are not referenced by the actual templates or components.

Sources: [1]

Before adoption

Dynamically generated class names may be invisible to static scanning

Classes composed in JavaScript, supplied by CMS content, or generated from runtime state can be removed unless they are covered by safelists or extractors.

Sources: [3]

Version 8 restores default PostCSS-plugin imports and Node 18 support had already been dropped

v8.0.0 changed @fullhuman/postcss-purgecss back to a default import. The v7 changelog states that Node 18 support was dropped, while the v8 purgecss package itself does not declare an engines field.

Sources: [6][5][4]

Official sources

  1. [1]PurgeCSS v8.0.0 README(2026-10-05)
  2. [2]PurgeCSS v8 CLI guide(2026-10-05)
  3. [3]PurgeCSS v8 safelisting guide(2026-10-05)
  4. [4]PurgeCSS v8.0.0 package metadata(2026-10-05)
  5. [5]PurgeCSS changelog(2026-10-05)
  6. [6]PurgeCSS v8.0.0 release(2026-10-05)
  7. [7]PurgeCSS MIT license(2026-10-05)
Supplemental curator note

PurgeCSS determines usage from content files, so class names created dynamically at runtime may not be visible to static scanning. Protect dynamic selectors with safelists or custom extractors and verify output with regression tests.

Try it in 3 steps

  1. 1

    Install PurgeCSS 8.0.0 in an isolated project

    Pin the stable release and test content scanning and unused-selector removal in isolation.

    demo=$(mktemp -d "${TMPDIR:-/tmp}/purgecss.XXXXXX") && cd "$demo" && npm init -y >/dev/null && npm install --save-exact --save-dev purgecss@8.0.0
  2. 2

    Create HTML and CSS with used and unused selectors

    Prepare one selector referenced by the HTML and one selector that should be removed.

    printf "%s\n" '<div class="used">Hello</div>' > index.html && printf "%s\n" '.used { color: green; }' '.unused { color: red; }' > styles.css
  3. 3

    Run the CLI and verify the unused selector is gone

    Confirm PurgeCSS keeps the referenced selector while removing the unused rule.

    mkdir build && npx purgecss --css styles.css --content index.html --output build && grep -q ".used" build/styles.css && ! grep -q ".unused" build/styles.css
Check the official README

Growth

Growth trends · Last 30 days

8,050 Stars

Trend data is still being collected.

Built with

Categories and tags

Categories

GitHub data

GitHub dataView detailed GitHub data

GitHub Topics

  • css
  • optimization-tools
  • postcss
  • postcss-plugin
  • purgecss
  • rollup-plugin
  • webpack-plugin
Stars
8,050
Forks
244
Watchers
55
Open issues
68
Owner type
Organization
Primary language
TypeScript
License
MIT
Repository last updated
Aug 20, 2026
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?