Pankaj Patel
Pankaj Patel

Pankaj Patel

Today's npm package: html-minifier

Today's npm package: html-minifier

Pankaj Patel's photo
Pankaj Patel
·Jun 16, 2021·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

Today's npm package is html-minifier

Optimization is the core goal of Computer Science and can bee applied to small areas like delivering HTML to browsers.

And to optiimize thee HTML delivery, first thing to come in mind is the minification of HTML

html-minifier is going to help us in this direction. Let's see how to use it:

const HTMLMinifier = require("html-minifier");

const minify = HTMLMinifier.minify;

const minifiedHtml = minify(
  '<h1 class="primary" id="main">Title</h1>',
  { removeAttributeQuotes: true }
);

console.log(minifiedHtml);
 // '<h1 class=primary id=main>Title</h1>'

See it in action here: runkit.com/pankaj/html-minifier

Stay tuned for tomorrow's package of the Day.

 
Share this