# Programmatic API

Start by installing PurgeCSS as a dev dependency.

npm i -D purgecss

You can now use PurgeCSS inside a JavaScript file.

In the following examples, the options passed to PurgeCSS are the same as the ones here. The result purgecssResult is an array of an object containing the name of the files with the purged CSS.

# Usage

import PurgeCSS from 'purgecss'
const purgeCSSResult = await new PurgeCSS().purge({
  content: ['**/*.html'],
  css: ['**/*.css']

The format of purgeCSSResult is

        file: 'main.css',
        css: '/* purged css for main.css */'
        file: 'animate.css',
        css: '/* purged css for animate.css */'

The type of the result is

interface ResultPurge {
  css: string;
  file?: string;
  rejected?: string[];


Take a look at the type definition file to get the complete information. Definition file