Registry / devops / jstransformer-html-minifier

jstransformer-html-minifier

JSON →
library4.0.0jsnpmunverified

JSTransformer plugin for html-minifier v4.0.0, enabling HTML minification via the JSTransformers interface. Uses html-minifier under the hood. Minimal release cadence; no updates since v4.0.0. Key differentiator: integrates with JSTransformers ecosystem for template engines like Pug, EJS, etc. Requires JSTransformers core to be installed separately.

npm install jstransformer-html-minifier
INSTALL
IMPORT
SIG · JSTRANSFORMER-HTML
J
jstransformer-html-minifier
devopsjavascriptv4.0.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.

jstransformer-html-minifier
const htmlmin = require('jstransformer')(require('jstransformer-html-minifier'))
This package is not used directly but via the jstransformer wrapper. It exports a JSTransformer object.
jstransformer-html-minifier
import jstransformer from 'jstransformer'; import htmlmin from 'jstransformer-html-minifier'; const transformer = jstransformer(htmlmin);
import htmlmin from 'jstransformer-html-minifier'; // Direct use without jstransformer wrapper
ESM usage: must use jstransformer wrapper to get render method.
htmlmin.render
transformer.render(input, options).body
htmlmin.render(input, options).body; // htmlmin is not a transformer instance
The render method is on the transformer instance, not the imported module.

Shows how to use jstransformer-html-minifier via the jstransformer wrapper to minify HTML with options.

const jstransformer = require('jstransformer'); const htmlmin = jstransformer(require('jstransformer-html-minifier')); const result = htmlmin.render('<p title="blah" id="moo">html-minifier</p>', { removeAttributeQuotes: true }).body; console.log(result); //=> '<p title=blah id=moo>html-minifier</p>'
Debug
Known issues
gotchaThis package does not expose a direct .render() method; you must use the jstransformer wrapper.
fix
Use require('jstransformer')(require('jstransformer-html-minifier')).render(...)
affects: >=0.0.0
deprecatedJSTransformers ecosystem is largely unmaintained; consider directly using html-minifier.
fix
Switch to using html-minifier directly (require('html-minifier').minify).
affects: >=4.0.0
gotchaNode.js >=4 required; older versions not supported.
fix
Upgrade Node.js to version 4 or later.
affects: >=4.0.0
Errors
Common errors & fixes
TypeError: htmlmin.render is not a function
Using the module directly without jstransformer wrapper.
fix
Use jstransformer wrapper: require('jstransformer')(require('jstransformer-html-minifier')).render(...)
Error: Cannot find module 'jstransformer'
jstransformer not installed or not in node_modules.
fix
Run npm install jstransformer.
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies
jstransformerrequiredPeer dependency required to use the transformer API.
html-minifierrequiredUnderlying minification library, installed as a dependency.
Agent activity
3 hits · last 30 days
node
2
Resources
jstransformer-html-minifier — npm install jstransformer-html-minifier · libregistry