html-minifier-next v6.2.0 is a super-configurable, JavaScript-based HTML minifier that also handles in-document CSS, JavaScript, and SVG minification. It is the actively maintained successor of the now-unmaintained HTML Minifier Terser and original HTML Minifier by kangax. The library is optimized for speed, offers both CLI and Node.js API, supports preset configurations, and ships TypeScript definitions. It requires @swc/core as a peer dependency for JavaScript minification. Released with monthly cadence, it aims to be backwards-compatible with its predecessors while adding new features like zero-config mode and ignore-dir support.
npm install html-minifier-nextNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic usage: minify HTML string with options to collapse whitespace, remove comments, and inline CSS/JS minification.
Use import { minify } from 'html-minifier-next' or dynamic import: const { minify } = await import('html-minifier-next').Install @swc/core as a dependency: npm install @swc/core. Alternatively, provide a custom minifyJS function.
Always pass a string: const result = minify(String(html), options).
Use absolute paths or ensure the config file is in the project root when running CLI.
Explicitly set desired options. Use preset='comprehensive' via CLI or configure options programmatically.
Upgrade Node.js to >=14.0.0 (recommended >=16.14 for full ESM support).
Run 'npm install @swc/core' or set 'minifyJS: false'.
Use 'import { minify } from 'html-minifier-next'' instead of 'import minify from ...'.Use absolute path or change working directory: --config-file ./config/html-minifier.json