Registry / devops / your-html-minifier

your-html-minifier

JSON →
library0.2.0jsnpmunverified

your-html-minifier is a Koa middleware for minifying HTML responses using the popular html-minifier library. Version 0.2.0 provides a simple integration for Koa 2.x, allowing developers to easily enable HTML minification with options like collapseWhitespace, minifyCSS, and minifyJS. Compared to the original koajs/html-minifier, this package offers similar functionality but is maintained under the yourjs organization. The release cadence is not well documented, but it is a lightweight wrapper around the well-established html-minifier package.

npm install your-html-minifier
INSTALL
IMPORT
SIG · YOUR-HTML-MINIFIER
Y
your-html-minifier
devopsjavascriptv0.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
import htmlMinifier from 'your-html-minifier'
import { htmlMinifier } from 'your-html-minifier'
The module exports a single function as default. Named import will not work.
default
const htmlMinifier = require('your-html-minifier')
const { htmlMinifier } = require('your-html-minifier')
CommonJS require returns the default export directly, not an object.
default
import hM from 'your-html-minifier'
import { default as hM } from 'your-html-minifier'
Using default as a named import is unnecessary and may cause confusion.

Demonstrates how to use the htmlMinifier middleware in a Koa 2.x application with common minification options.

import Koa from 'koa'; import htmlMinifier from 'your-html-minifier'; const app = new Koa(); app.use(htmlMinifier({ collapseWhitespace: true, minifyCSS: true, minifyJS: true })); app.use(async (ctx) => { ctx.body = '<html><head></head><body> Hello World </body></html>'; }); app.listen(3000);
Debug
Known issues
gotchaThis package is a thin wrapper around html-minifier and inherits its options. Ensure you understand the html-minifier option documentation.
fix
Refer to https://github.com/kangax/html-minifier#options-quick-reference for all available options.
affects: all
breakingPossible breaking change if upgrading from earlier versions without proper peer dependency on Koa 2.x.
fix
Ensure your project uses Koa 2.x. For Koa 1.x, consider using koajs/html-minifier instead.
affects: <0.2.0
deprecatedThe package might not be actively maintained. No recent updates as of 2023.
fix
Consider using html-minifier-terser or other actively maintained alternatives.
affects: all
Errors
Common errors & fixes
TypeError: htmlMinifier is not a function
Using named import instead of default import in ESM.
fix
Use 'import htmlMinifier from "your-html-minifier"' instead of 'import { htmlMinifier } from "your-html-minifier"'.
html-minifier is not a function
Trying to use html-minifier directly without the wrapper.
fix
Use 'import htmlMinifier from "your-html-minifier"' and apply as middleware.
Cannot find module 'html-minifier'
Missing dependency on html-minifier. It should be automatically installed as a peer dependency.
fix
Run 'npm install html-minifier' in your project.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
html-minifierrequiredCore minification engine for HTML, CSS, and JS.
Agent activity
16 hits · last 30 days
node
14
Resources
your-html-minifier — npm install your-html-minifier · libregistry