Registry / devops / gulp-html-minifier-terser

gulp-html-minifier-terser

JSON →
library8.0.0jsnpmunverified

Gulp plugin to minify HTML using html-minifier-terser. Version 8.0.0 requires Node >=24. It provides a stream-friendly wrapper around html-minifier-terser, which itself is a fork of html-minifier that uses the terser parser for improved accuracy and performance. The plugin supports all options from html-minifier-terser, such as collapseWhitespace, removeComments, and minifyJS. Released under MIT, with maintenance kept in sync with upstream changes. Key differentiator from alternatives like gulp-htmlmin is the use of terser for parsing, which handles modern HTML constructs more reliably.

npm install gulp-html-minifier-terser
INSTALL
IMPORT
SIG · GULP-HTML-MINIFIER
G
gulp-html-minifier-terser
devopsjavascriptv8.0.0
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.

default (function)
import htmlmin from 'gulp-html-minifier-terser';
import { htmlmin } from 'gulp-html-minifier-terser';
Only a default export is available; named destructuring will fail.
default (CommonJS)
const htmlmin = require('gulp-html-minifier-terser');
CommonJS require is supported.
combined with TypeScript
import htmlmin from 'gulp-html-minifier-terser';
Type definitions are included; no need for separate @types package.

Shows a basic Gulp task that minifies HTML files using the plugin with common options.

const gulp = require('gulp'); const htmlmin = require('gulp-html-minifier-terser'); gulp.task('minify', () => { return gulp .src('src/*.html') .pipe(htmlmin({ collapseWhitespace: true, removeComments: true })) .pipe(gulp.dest('dist')); });
Debug
Known issues
breakingNode.js version requirement increased to >=24.0.0 in version 8.0.0.
fix
Upgrade Node.js to v24 or later, or pin to version 7.x.
affects: 8.0.0
gotchaOptions for html-minifier-terser are passed directly; misspelled options are silently ignored.
fix
Double-check option names against html-minifier-terser documentation.
affects: all
deprecatedThe option 'removeScriptTypeAttributes' has been deprecated in html-minifier-terser.
fix
Use 'removeAttributeQuotes' or custom processing instead.
affects: all
gotchaThe plugin does not preserve the source map from Gulp's vinyl objects; output files will not have source maps.
fix
If source maps are needed, consider using gulp-sourcemaps and a different minifier.
affects: all
deprecatedGulp 3 is no longer supported; plugin requires Gulp 4 or later.
fix
Upgrade to Gulp 4+ and use gulp.series or gulp.parallel.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'gulp-html-minifier-terser'
Package not installed or not in node_modules.
fix
Run 'npm install gulp-html-minifier-terser --save-dev'.
TypeError: htmlmin is not a function
Using named import instead of default import.
fix
Use 'import htmlmin from ...' or 'const htmlmin = require(...)'.
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Trying to require() an ES module in a CommonJS script without --experimental-require-module.
fix
Switch to ESM (use 'import' syntax) or use dynamic import.
TypeError: Cannot destructure property 'collapseWhitespace' of 'undefined'
Options object not provided or undefined.
fix
Pass an options object even if empty: htmlmin({}).
Error: The 'src' argument must be of type string. Received undefined
Gulp.src() without a glob pattern.
fix
Provide a string glob pattern to gulp.src().
Upgrade
Version history
8.0.0latest on npm
Audit
Dependencies
html-minifier-terserrequiredCore HTML minification engine; all options are passed through.
gulprequiredPeer dependency; plugin is designed to work within Gulp pipelines.
Agent activity
4 hits · last 30 days
node
4
Resources
gulp-html-minifier-terser — npm install gulp-html-minifier-terser · libregistry