unused css rules tree shaking elimination nodejs

Unused css rules elimination process is a lot more like tree shaking done by JavaScript bundlers for instance if you're familiar with how webpack eliminates dead code as a result tree shaking generates a much smaller bundle with only essential code

Purifycss is a nodejs npm open source package that eliminates unused css
You can use purifycss to remove excess css from libraries such as bootstrap, materal design lite to name a few,


You can get "purify-css" npm package from the package manager by typing in your terminal;

npm i purify-css

To install globally add -g flag;

npm i -g purify-css

Basic example usage;
You can use css purify global cli package as;


purifycss {css} {html}

Important flags;

-m minify output
-o specify output file name

For example;

purifycss *.css *.html -o css.min.css

Output containg minified css rules will get saved to css.min.css


Popular posts from this blog

How to set content disposition header for nginx server to force content download

How to create zip archives in nodejs

How to make a Snake Game using JavaScript and html5

How to draw clouds on HTML5 Canvas

How to resume a suspended web audio api context