Koa middleware that minifies HTML responses using html-minifier-terser. Version 3.0.0 is the current stable release (last updated 2021). It wraps html-minifier-terser's default options (all off), so minification only occurs if explicitly configured. Unlike other HTML minifiers for Koa (e.g., koa-html-minify), this one uses the actively maintained terser fork with better ES6+ support. Requires Node >= 12 and works with Koa 2.
npm install koa-html-minifierNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic setup with koa-compress and html minification. Demonstrates that minify options must be explicitly set (defaults to no-op).
Pass at least one minification option, e.g., `{ collapseWhitespace: true }`.Call `app.use(compress())` before `app.use(minify(...))`.
Upgrade to Node >= 12 or stay on version 2.x.
Review html-minifier-terser options; some html-minifier options may be removed or renamed.
Use `import minify from 'koa-html-minifier'` (ESM) or `const minify = require('koa-html-minifier')` (CJS).Run `npm install html-minifier-terser` alongside koa-html-minifier.
Ensure your routes set `Content-Type` to `text/html` or use the middleware only for HTML routes.