PurgeCSS

Open Source

by PurgeCSS

Provided by PurgeCSS

Not yet rated
Platform
Web
Pricing
Open Source
Account required
No
Ads
None
Last verified
40 minutes ago
Developer
PurgeCSS
Official URL

Overview

PurgeCSS is an open-source build tool that strips unused rules out of your stylesheets. It reads your content files, such as HTML, templates and JavaScript, works out which selectors they actually use, and removes everything else from the CSS. On projects built with large frameworks, where only a fraction of the styles are ever used, that can make the shipped stylesheet much smaller.

It is used from the command line, through a JavaScript API, or as a plugin for PostCSS, webpack, Rollup, Gulp, Grunt and Gatsby, so it slots into most front-end build setups. Matching is done by extractors, and you can write your own extractor for a file type the defaults do not handle well.

Because it only sees class names that appear as text in your files, anything built up dynamically at run time can be removed by mistake. The safelist option, by name or by pattern, is how you protect those selectors. PurgeCSS is MIT licensed and maintained by Full Human.

Features

  • Removes CSS selectors that your content files never use
  • Command line interface and JavaScript API
  • Plugins for PostCSS, webpack, Rollup, Gulp, Grunt and Gatsby
  • Safelist selectors by exact name or by pattern
  • Custom extractors for any file type
  • MIT licensed

Privacy

PurgeCSS runs locally as part of your own build, so your code is not uploaded anywhere. The documentation site itself loads Google Analytics.

Pros & Cons

Pros

  • Free and open source
  • Fits into most common build tools
  • Can cut stylesheet size a lot on framework-heavy sites
  • Safelists and custom extractors give control over edge cases

Cons

  • A developer tool that needs a Node.js build setup, not a point-and-click app
  • Class names generated dynamically in code can be removed unless safelisted
  • Needs careful configuration and testing to avoid broken styling

Community Reviews (0)

No written reviews yet — be the first to rate this tool.

Similar Tools

  • Checks CSS for errors and standards compliance.

    Not yet rated
    Open Source Web API
  • Provides tips, tricks, and reference guides for CSS.

    Not yet rated
    Free Web
  • CSS · cssnano

    Minifies CSS as part of a PostCSS build pipeline.

    Not yet rated
    Open Source Web