Today's npm package: html-minifier-terser

I am developer from India currently based in Berlin, Germany.
I am very interested in Design, though I don't design 😉 I take care of it while making my apps.
Photography, videography and having random conversation over beer are my activities of spare time. Timelapses and hyperlapses make me wonder all the time 😊
Today's npm package is html-minifier-terser
Minifying the final HTML is better for reducing the size of network response and hence speeding up your website.
html-minifier-terser as a highly customizable minifier is going to help us in this direction.
Here's how to use it for the following HTML
<div id="app" class="container">
<aside class="app-menu">Menu</aside>
<main class="app-content">Content area</main>
</div>
Following Node.js script would minify the supplied HTML:
const { minify } = require('html-minifier-terser');
const result = minify(
`<div id="app" class="container">
<aside class="app-menu">Menu</aside>
<main class="app-content">Content area</main>
</div>`,
{ removeAttributeQuotes: true }
);
console.log(result);
// <div id=app class=container>\n <aside class=app-men… <main class=app-content>Content area</main>\n </div>
See it in action here: https://runkit.com/pankaj/html-minifier-terser
Stay tuned for tomorrow's package of the Day.




