HTMLMinifier is a highly configurable, well-tested JavaScript-based HTML minifier for Node.js (version 4.2.0). It compresses HTML by removing unnecessary whitespace, comments, and redundant attributes, with options for custom attribute removal. Compared to alternatives like htmlcompressor and minimize, it consistently achieves superior size reduction (e.g., 42 KB vs 46 KB on Google homepage). The package supports CLI and programmatic usage, and is actively maintained with regular releases.
npm install html-minifier-with-remove-custom-attrsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Minifies an HTML file with whitespace collapse, comment removal, CSS/JS minification, and custom attribute removal using HTMLMinifier.
Use 'customAttrRemove' (boolean) or 'customAttrRemoveRegexes' (array) instead.
Avoid 'decodeEntities' if you need to preserve non-ASCII characters.
Install optional dependencies: npm install clean-css uglify-js
Set 'conservativeCollapse' to false and test output; consider 'preserveLineBreaks'.
Replace 'removeEmptyAttributes' with 'removeEmpty' in options.
Use const { minify } = require('html-minifier') or const minify = require('html-minifier').minify.Run npm install clean-css (and uglify-js if minifyJS is true).
Use customAttrRemoveRegexes: [/^\[.*\]$/] to match Angular attribute syntax.
Set decodeEntities: false.