Registry / devops / express-minify-html-3

express-minify-html-3

JSON →
library1.2.0jsnpmunverified

Express middleware that wraps html-minifier-with-remove-custom-attrs to minify HTML responses. Version 1.2.0 is the latest stable release. This is a fork of the original express-minify-html package intended to keep the project alive. It enhances the res.render method (or adds res.renderMin) to automatically minify HTML output. Compared to alternatives like express-minify or express-html-minifier, this package specifically uses html-minifier-with-remove-custom-attrs for compatibility. Release cadence is low, with no recent updates.

npm install express-minify-html-3
INSTALL
IMPORT
SIG · EXPRESS-MINIFY-HTM
E
express-minify-html-3
devopsjavascriptv1.2.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
const minifyHTML = require('express-minify-html-2');
import minifyHTML from 'express-minify-html-2';
Package is CJS-only, no ESM bindings
minifyHTML
const minifyHTML = require('express-minify-html-2');
const minify = require('express-minify-html-2').minifyHTML;
Default export is the function; no named export exists
MiddlewareOptions
No type exports; configure inline object
import { MiddlewareOptions } from 'express-minify-html-2';
Package does not ship TypeScript declarations

Demonstrates basic setup with express, enabling minification via middleware and using res.render.

const express = require('express'); const minifyHTML = require('express-minify-html-2'); const app = express(); app.use(minifyHTML({ override: true, exception_url: false, htmlMinifier: { removeComments: true, collapseWhitespace: true, collapseBooleanAttributes: true, removeAttributeQuotes: true, removeEmptyAttributes: true, minifyJS: true } })); app.get('/hello', function (req, res, next) { res.render('helloTemplate', { hello: 'world' }); }); app.listen(3000);
Debug
Known issues
gotchaUsing override: true will hijack res.render. If other middleware also modifies res.render, they may conflict.
fix
Set override: false and use res.renderMin instead to avoid conflicts.
affects: >=1.0.0
deprecatedPackage is a fork in maintenance mode; original express-minify-html may be considered deprecated.
fix
Consider using express-minify or express-html-minifier as more active alternatives.
affects: >=1.0.0
gotchaThe htmlMinifier options are passed directly to html-minifier-with-remove-custom-attrs which may have different defaults than html-minifier.
fix
Review https://github.com/kangax/html-minifier for available options; test output carefully.
affects: >=1.0.0
breakingThis package does not support ESM (import syntax). Using it in an ESM project requires dynamic require or transpilation.
fix
Use createRequire or stick to CommonJS.
affects: >=1.0.0
gotchaThe exception_url option accepts arrays of strings, regexes, and functions; using a single non-array value works but may be confusing.
fix
Always pass an array for multiple exceptions; wrapping a single value in an array is also safe.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: minifyHTML is not a function
Importing package in ESM context without proper handling.
fix
const minifyHTML = require('express-minify-html-2'); (CommonJS) or use createRequire.
Error: Module not found: html-minifier-with-remove-custom-attrs
Missing dependency when package was installed without production flag.
fix
Run npm install --save --production express-minify-html-2 or manually install html-minifier-with-remove-custom-attrs.
TypeError: Cannot read property 'render' of undefined
Middleware applied before app initializes or without express app.
fix
Ensure app is an Express instance and app.use is called after app creation.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
expressrequiredpeer dependency required as middleware
html-minifier-with-remove-custom-attrsrequiredcore minification engine
Agent activity
2 hits · last 30 days
node
2
Resources
express-minify-html-3 — npm install express-minify-html-3 · libregistry