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,

Installation

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;

Syntax;

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

Comments

Popular posts from this blog

Open-graph meta data tags introdution

What is 'this.' keyword in JavaScript

what is 'array.includes' function in JavaScript

What is a bin directory

How to build a twitter retweet bot using JavaScript