Skip to content

Repository files navigation

Build StatusBuild StatusDownloads in week

Remove unused CSS | rm-unused-css

Remove unused css and duplicated css rules from your website. This tool removes duplicated rules and searches in html and js for unused css. Please keep in mind that not all unused css can be found, because of js injections! In my test 80-90% of unused css can be removed. This supports all kind off css frameworks, bootstrap, tailwindcss, foundation and more....

Check out the webpack plugin for usage with webpack.

Installing

To utilize for node.js install the the npm module:

$ npm install rm-unused-css --save

Check out the example folder!

constrmUnusedCss=require('rm-unused-css');constcssSource='css/style.css';rmUnusedCss(cssSource,{path: './**/+(*.html|*.htm|*.js)',override: true}).then((result)=>{console.log(result.file,result.newContent)});

Source: [cssSource]

Could be a single file path, array or a string with CSS content.

Options

{// Glob path to the js and html files. Set to null or false if you don't want to remove unused selectorspath: '**/+(*.html|*.htm|*.js)',// Override the input fileoverride: false,// exclude filesexclude: [],// RegExp css class patterns. Example: /myclass_.*/whitelistPatterns: [],blacklistPatterns: [],// glob package optionsglobOptions: {ignore: 'node_modules/**/*'}}

Build Plugin

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Donate

Donate with Bitcoin

About

πŸ–– Remove unused css and duplicate css rules.

Resources

Stars

12 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages