Koa 2.x middleware that minifies HTML responses using html-minifier. Version 1.0.7 is the latest stable release; development appears maintenance-mode with no recent updates. It is a straightforward port of the original koajs/html-minifier for Koa 2.x. Key differentiator: lightweight, no extra configuration beyond html-minifier options. However, all html-minifier defaults are off, so you must explicitly enable minification features.
npm install koa-html-minifier2No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up a Koa app with HTML minification middleware; shows enabling common options.
Pass an options object with at least one minification feature enabled, e.g., { collapseWhitespace: true }.Consider alternatives like koa-html-minifier or direct use of html-minifier in middleware.
Ensure your responses have the correct Content-Type header.
Skip middleware for streaming responses by checking ctx.body is a stream.
Use const htmlMinifier2 = require('koa-html-minifier2')npm install html-minifier
Pass an options object with at least one true option, e.g., { collapseWhitespace: true }.