Registry / devops / html-minifier-es6

html-minifier-es6

JSON →
library3.5.9jsnpmunverified

A fork of html-minifier that adds basic ES6 uglification support via the minifyJS option set to 'es6'. Version 3.5.9 is the latest stable release. It includes TypeScript definitions. This package is a thin wrapper around the original html-minifier, with no active maintenance or updates expected. It allows older projects that need ES6-aware minification to continue using a familiar API, but users should consider migrating to modern alternatives like html-minifier-terser for better ES6+ support.

npm install html-minifier-es6
INSTALL
IMPORT
SIG · HTML-MINIFIER-ES6
H
html-minifier-es6
devopsjavascriptv3.5.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

minify
import { minify } from 'html-minifier-es6'
import minify from 'html-minifier-es6'
Named export, not default. Works in ESM and CJS.
minify
const { minify } = require('html-minifier-es6')
const minify = require('html-minifier-es6')
CommonJS: destructure to get the named export.

Minify an HTML string with ES6 JS support enabled via minifyJS option set to 'es6'.

import { minify } from 'html-minifier-es6'; const html = ` <!DOCTYPE html> <html> <head> <title>Test</title> </head> <body> <p>Hello World</p> <script> const x = 1; const y = () => x + 1; console.log(y()); </script> </body> </html> `; const result = minify(html, { removeComments: true, collapseWhitespace: true, minifyJS: 'es6' }); console.log(result);
Debug
Known issues
deprecatedPackage is a fork that has not been actively maintained. Use html-minifier-terser instead.
fix
Replace 'html-minifier-es6' with 'html-minifier-terser' and update options accordingly.
affects: >=3.5.9
breakingThe 'minifyJS' option set to 'es6' uses a simple uglifier that may not handle modern ES6+ syntax correctly (e.g., optional chaining, nullish coalescing).
fix
Use html-minifier-terser with minifyJS: true or a proper terser configuration.
affects: *
gotchaThe package exports only a named 'minify' function, not a default export.
fix
Use `import { minify } from 'html-minifier-es6'` or `const { minify } = require('html-minifier-es6')`.
affects: *
Errors
Common errors & fixes
TypeError: htmlmin.minify is not a function
Importing default instead of named export.
fix
Use `const { minify } = require('html-minifier-es6');`
ReferenceError: primordials is not defined
Incompatibility with Node.js >= 12 due to old dependencies (graceful-fs).
fix
Use a newer alternative like html-minifier-terser or downgrade Node.js to < 12.
SyntaxError: Unexpected token 'const'
The built-in 'es6' uglifier cannot parse newer JS syntax like const/let in some cases.
fix
Set minifyJS to a custom uglifier (e.g., terser) instead of 'es6'.
Upgrade
Version history
3.5.9latest on npm
Audit
Dependencies
html-minifierrequiredoriginal minifier library; this fork extends it
Agent activity
6 hits · last 30 days
node
6
Resources
html-minifier-es6 — npm install html-minifier-es6 · libregistry