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-3No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic setup with express, enabling minification via middleware and using res.render.
Set override: false and use res.renderMin instead to avoid conflicts.
Consider using express-minify or express-html-minifier as more active alternatives.
Review https://github.com/kangax/html-minifier for available options; test output carefully.
Use createRequire or stick to CommonJS.
Always pass an array for multiple exceptions; wrapping a single value in an array is also safe.
const minifyHTML = require('express-minify-html-2'); (CommonJS) or use createRequire.Run npm install --save --production express-minify-html-2 or manually install html-minifier-with-remove-custom-attrs.
Ensure app is an Express instance and app.use is called after app creation.