Skip to main content

Command Palette

Search for a command to run...

Today's npm package: html-minifier

Published
1 min read
Today's npm package: html-minifier

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: https://runkit.com/pankaj/html-minifier

Stay tuned for tomorrow's package of the Day.

More from this blog

P

Pankaj Patel - @heypankaj_

63 posts

Sharing my learnings and thoughts on Blogging, Personal Branding and Programming