Purgecss

Remove unused CSS

README

PurgeCSS

npm
npm
GitHub
Dependabot

PurgeCSS logo


What is PurgeCSS?


When you are building a website, chances are that you are using a css framework like Bootstrap, Materializecss, Foundation, etc... But you will only use a small set of the framework and a lot of unused css styles will be included.

This is where PurgeCSS comes into play. PurgeCSS analyzes your content and your css files. Then it matches the selectors used in your css files with the ones in your content files. It removes unused selectors from your css, resulting in smaller css files.

Sponsors 🥰


[](https://tailwindcss.com)

Documentation


You can find the PurgeCSS documentation on this website.

Table of Contents


PurgeCSS



Plugins



Guides



Getting Started


Installation


  1. ```sh
  2. npm install purgecss --save-dev
  3. ```

Usage


  1. ``` js
  2. import { PurgeCSS } from "purgecss";
  3. const purgeCSSResults = await new PurgeCSS().purge({
  4.   content: ["**/*.html"],
  5.   css: ["**/*.css"],
  6. });
  7. ```

Packages


This repository is a monorepo that we manage using Lerna. That means that we actually publish several packages to npm from the same codebase, including:

PackageVersionDescription
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[purgecss](/packages/purgecss)![npm](https://img.shields.io/npm/v/purgecss?style=flat-square)The
[postcss-purgecss](/packages/postcss-purgecss)![npmPostCSS
[purgecss-webpack-plugin](/packages/purgecss-webpack-plugin)![npm](https://img.shields.io/npm/v/purgecss-webpack-plugin?style=flat-square)Webpack
[gulp-purgecss](/packages/gulp-purgecss)![npm](https://img.shields.io/npm/v/gulp-purgecss?style=flat-square)Gulp
[grunt-purgecss](/packages/grunt-purgecss)![npm](https://img.shields.io/npm/v/grunt-purgecss?style=flat-square)Grunt
[rollup-plugin-purgecss](/packages/rollup-plugin-purgecss)![npm](https://img.shields.io/npm/v/rollup-plugin-purgecss?style=flat-square)Rollup
[purgecss-from-html](/packages/purgecss-from-html)![npm](https://img.shields.io/npm/v/purgecss-from-html?style=flat-square)Html
[purgecss-from-pug](/packages/purgecss-from-pug)![npm](https://img.shields.io/npm/v/purgecss-from-pug?style=flat-square)Pug
[purgecss-with-wordpress](/packages/purgecss-with-wordpress)![npm](https://img.shields.io/npm/v/purgecss-with-wordpress?style=flat-square)Collection
[vue-cli-plugin-purgecss](/packages/vue-cli-plugin-purgecss)![npm](https://img.shields.io/npm/v/@fullhuman/vue-cli-plugin-purgecss?style=flat-square)Vue