Modular HTML minifier built on PostHTML, version 3.2.1 (stable). Released occasionally, with recent versions focusing on TypeScript migration, performance improvements, and edge case fixes. Key differentiators: modular architecture allowing selective enabling/disabling of minification modules, presets (safe, max), and extensive configuration options. Compared to html-minifier-terser or minify-html, htmlnano offers deeper integration with PostHTML ecosystem and supports advanced features like CSS/JS minification via optional peer dependencies (cssnano, terser). Includes CLI tool and TypeScript types.
npm install htmlnanoNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic usage of htmlnano to minify HTML with whitespace collapse option.
Review SVGO v4 migration guide; adjust SVG optimization options if needed.
Replace callback with async/await or .then().
Use ESM import or upgrade to v2.1.6+.
Install types for optional peer dependencies (e.g., @types/cssnano) if needed.
Install purgecss as peer dependency if using removeUnusedCss.
Install cssnano: npm install cssnano --save-dev
Use import htmlnano from 'htmlnano' instead of require.
Use 'safe' or 'max' (string) as preset, or omit to use default.