PurgeCSS is a CSS optimization tool that removes unused styles from your stylesheets.
The tool solves the problem of bloated CSS files when using frameworks like Bootstrap or Foundation, where you typically use only a fraction of the available styles. PurgeCSS analyzes your content files and CSS files, then matches selectors in your CSS against those actually used in your content. It removes any unused selectors, resulting in significantly smaller CSS files that are delivered to users.
The tool suits projects using CSS frameworks or large stylesheets where unused styles accumulate. It integrates into common build workflows through plugins for PostCSS, Webpack, Gulp, and Grunt, and includes framework-specific guides for Vue.js, React, Next.js, Nuxt.js, and other popular tools. An online version is available for testing before integration. The documentation includes configuration options, a command-line interface, a programmatic API, safelisting capabilities for protecting styles from removal, and custom extractors for matching selectors in non-standard file formats.
The project is organized as a monorepo using Lerna, publishing multiple packages to npm from a single codebase. Development activity shows consistent engagement with the codebase, regular updates to address issues and maintain compatibility with evolving build tools and frameworks, and active documentation maintenance reflecting the tool's integration points across the ecosystem.