Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

purgecss

> 前端框架
Open source

Remove unused CSS

8.0K stars0 likes3 views
WebsiteGitHub

About

Remove unused CSS

PurgeCSS

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.

You can try PurgeCSS online at purgecss.full-human.com.

Sponsors

Documentation

You can find the PurgeCSS documentation on this website.

Table of Contents

PurgeCSS

  • Configuration
  • Command Line Interface
  • Programmatic API
  • Safelisting
  • Extractors
  • Comparison

Plugins

  • PostCSS
  • Webpack
  • Gulp
  • Grunt
  • Gatsby

Guides

  • Vue.js
  • Nuxt.js
  • React.js
  • Next.js
  • Razzle
  • Hugo

Getting Started

Installation

bash
npm install purgecss --save-dev

Usage

javascript
import { PurgeCSS } from "purgecss";
const purgeCSSResults = await new PurgeCSS().purge({
  content: ["**/*.html"],
  css: ["**/*.css"],
});

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:

Package Version Description
purgecss The core of PurgeCSS
postcss-purgecss PostCSS plugin for PurgeCSS
purgecss-webpack-plugin Webpack plugin for PurgeCSS
gulp-purgecss Gulp plugin for PurgeCSS
grunt-purgecss Grunt plugin for PurgeCSS
rollup-plugin-purgecss Rollup plugin for PurgeCSS
purgecss-from-html Html extractor for PurgeCSS
purgecss-from-pug Pug extractor for PurgeCSS
purgecss-with-wordpress Collection of safelist items for WordPress
vue-cli-plugin-purgecss Vue CLI Plugin for PurgeCSS

Issues· 68 open

View all issuesOpen on GitHub
  • #978

    [Bug]: :is and :where selector lists are purged regardless of matching elements

    bugcoming soonUpdated Jul 8, 2026
  • #1197

    [Bug]: `:where` is incorrectly purged when it is a child of `:not`

    bugUpdated Jul 8, 2026
  • #1282

    [Bug]: Most pseudo-classes incorrectly purged when there is no selector before it

    bugUpdated Jul 8, 2026
  • #996

    feature_request(option): automatic generation of HTML lists

    Updated Jun 13, 2026
  • #1012

    Update Vue3 and Nuxt.js integration guide

    help wanteddocumentationUpdated Jun 1, 2026
  • #1326

    [Bug]: PurgeCSS ESM Loader Fails on Windows Drive Letters

    bugUpdated Jan 2, 2026
  • #1348

    [Bug]: Jinja2 Templating css gets Purged!

    bugUpdated Apr 22, 2025
  • #1347

    [Bug]: CSS variables under nested media queries get purged

    bugUpdated Apr 17, 2025
  • #1339

    [Bug]: [blocklist] can't remove [type='button'] selector

    bugUpdated Mar 21, 2025
  • #1325

    [Bug]: Remove unused `@property` rules

    bugUpdated Feb 15, 2025

> Tags

TypeScriptcssoptimization-toolspostcsspostcss-plugin

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 1, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架