Almost all of the html-minifier options are disabled by default.
Try with some options:
{
collapseWhitespace: true,
removeComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
}
Answer from Bertrand Marron on Stack Overflownpm
npmjs.com › package › html-minifier
html-minifier - npm
April 1, 2019 - Highly configurable, well-tested, JavaScript-based HTML minifier.. Latest version: 4.0.0, last published: 7 years ago. Start using html-minifier in your project by running `npm i html-minifier`. There are 2178 other projects in the npm registry using html-minifier.
» npm install html-minifier
Published Apr 01, 2019
Version 4.0.0
Author Juriy "kangax" Zaytsev
Repository https://github.com/kangax/html-minifier
npm
npmjs.com › package › minify
minify - npm
2 weeks ago - Minifier of js, css, html and img. Latest version: 15.2.0, last published: 15 days ago. Start using minify in your project by running `npm i minify`. There are 217 other projects in the npm registry using minify.
» npm install minify
Published Mar 04, 2026
Version 15.2.0
Author coderaiser
Repository https://github.com/coderaiser/minify
Homepage http://coderaiser.github.io/minify
npm
npmjs.com › package › @node-minify › html-minifier
@node-minify/html-minifier - npm
2 weeks ago - A very light minifier Node.js module. ... It allow you to compress HTML files. npm install @node-minify/core @node-minify/html-minifier
» npm install @node-minify/html-minifier
Published Mar 08, 2026
Version 10.5.0
Author Rodolphe Stoclin
Repository https://github.com/srod/node-minify
npm
npmjs.com › package › html-minifier-terser
html-minifier-terser - npm
April 11, 2023 - Highly configurable, well-tested, JavaScript-based HTML minifier.. Latest version: 7.2.0, last published: 3 years ago. Start using html-minifier-terser in your project by running `npm i html-minifier-terser`. There are 796 other projects in the npm registry using html-minifier-terser.
» npm install html-minifier-terser
Published Apr 11, 2023
Version 7.2.0
Author Daniel Ruf
GitHub
github.com › srod › node-minify
GitHub - srod/node-minify: Light Node.js module that compress javascript, css and html files · GitHub
A very light minifier Node.js module. It allows you to compress JavaScript, CSS, HTML, and image files. ... npm install @node-minify/core # Or Yarn yarn add @node-minify/core # Or pnpm pnpm add @node-minify/core # Or Bun bun add @node-minify/core
Starred by 516 users
Forked by 50 users
Languages TypeScript 99.2% | JavaScript 0.8%
GitHub
github.com › jdedwards3 › devextent › blob › main › content › posts › npm-minify-html.md
devextent/content/posts/npm-minify-html.md at main · jdedwards3/devextent
The html-minifier npm package provides a command line interface that makes it possible to minify HTML. This can be useful when working with a site built with the Jamstack. One example of this scenario could be a site that uses a static site ...
Author jdedwards3
npm
npmjs.com › package › @minify-html › node
@minify-html/node - npm
March 22, 2025 - A Rust HTML minifier meticulously optimised for speed and effectiveness, with bindings for other languages.
» npm install @minify-html/node
Published Oct 25, 2025
Version 0.18.1
Author Wilson Lin
Repository https://github.com/wilsonzlin/minify-html
npm
npmjs.com › package › html-minifier-next
html-minifier-next - npm
February 4, 2026 - Super-configurable and well-tested web page minifier (enhanced successor of HTML Minifier). Latest version: 5.1.5, last published: an hour ago. Start using html-minifier-next in your project by running `npm i html-minifier-next`. There are 9 other projects in the npm registry using html-minifier-next.
» npm install html-minifier-next
Published Feb 26, 2026
Version 5.1.5
Author Jens Oliver Meiert
Repository https://github.com/j9t/html-minifier-next
npm
npmjs.com › package › html-minify
html-minify - npm
minify html, and any CSS or JS included in your markup. Latest version: 0.3.2, last published: 9 years ago. Start using html-minify in your project by running `npm i html-minify`. There are 8 other projects in the npm registry using html-minify.
» npm install html-minify
GitHub
github.com › kangax › html-minifier
GitHub - kangax/html-minifier: Javascript-based HTML compressor/minifier (with Node.js support) · GitHub
npm install html-minifier -g · From NPM for programmatic use: npm install html-minifier · From Git: git clone git://github.com/kangax/html-minifier.git cd html-minifier npm link .
Starred by 5.1K users
Forked by 582 users
Languages JavaScript 94.9% | HTML 4.6% | CSS 0.5%
Kangax
kangax.github.io › html-minifier
HTML minifier
Max. line length Specify a maximum line length. Compressed output will be split by newlines at valid HTML split-points
npm
npmjs.com › package › @minify-html › js
@minify-html/js - npm
Extremely fast and smart HTML + JS + CSS minifier. Latest version: 0.8.1, last published: 4 years ago. Start using @minify-html/js in your project by running `npm i @minify-html/js`. There are 5 other projects in the npm registry using @minify-html/js.
» npm install @minify-html/js
Published Jun 17, 2022
Version 0.8.1
Author Wilson Lin
Repository https://github.com/wilsonzlin/minify-html
npm
npmjs.com › package › minify-html-attributes
minify-html-attributes - npm
March 10, 2025 - A Node.js module that will minify HTML attribute class names, IDs, and data-* attributes in a coordinated fashion across your HTML, CSS, and JS files. This is useful if you want to minify your code even more than standard minifiers do, or if ...
» npm install minify-html-attributes
Published Mar 10, 2025
Version 1.0.2
Author Roosevelt Framework Team
npm
npmjs.com › package › @types › html-minifier
@types/html-minifier - npm
October 24, 2025 - TypeScript definitions for html-minifier. Latest version: 4.0.6, last published: 3 months ago. Start using @types/html-minifier in your project by running `npm i @types/html-minifier`. There are 74 other projects in the npm registry using @types/html-minifier.
» npm install @types/html-minifier
Published Oct 24, 2025
Version 4.0.6
Tabnine
tabnine.com › home page › code › javascript › html-minifier
html-minifier JavaScript and Node.js code examples | Tabnine
think.beforeStartServer(async() => { // 压缩模板 if (think.env === 'production') { if (!fs.existsSync(think.ROOT_PATH + '/runtime/')) { fs.mkdirSync(think.ROOT_PATH + '/runtime/'); } if (!fs.existsSync(think.ROOT_PATH + '/runtime/view/')) { fs.mkdirSync(think.ROOT_PATH + '/runtime/view/'); } var minify = require('html-minifier').minify; const views = fs.readdirSync(think.ROOT_PATH + '/view'); views.forEach((val, index) => { const data = fs.readFileSync(think.ROOT_PATH + '/view/' + val, 'utf8'); const minifyData = minify(data, {removeComments: true, collapseWhitespace: true, minifyJS: true, minifyCSS: true}); fs.writeFileSync(think.ROOT_PATH + '/runtime/view/' + val, minifyData); }); } });
npm
npmjs.com › search
html minifier - npm search
An Rsbuild plugin to use [html-minifier-terser](https://github.com/terser/html-minifier-terser) to minify the HTML outputs.
npm
npmjs.com › package › @frontendista › html-minifier-terser
@frontendista/html-minifier-terser - npm
July 24, 2023 - HTML minifier that uses LightningCSS and ESBuild for minification.
» npm install @frontendista/html-minifier-terser
Published Jul 24, 2023
Version 0.2.2
Author Pavel Sušický