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

What is 'this.' keyword in JavaScript

How to get user's ip address in JavaScript

How to make a static http server in nodejs using express

How to create promises in JavaScript

what is 'array.includes' function in JavaScript