Registry /
devops / jstransformer-html-minifier
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>'
Errors
Common errors & fixes
TypeError: htmlmin.render is not a function
Using the module directly without jstransformer wrapper.
fixUse jstransformer wrapper: require('jstransformer')(require('jstransformer-html-minifier')).render(...) Error: Cannot find module 'jstransformer'
jstransformer not installed or not in node_modules.
fixRun npm install jstransformer.
Audit
Dependencies
jstransformerrequiredPeer dependency required to use the transformer API.
html-minifierrequiredUnderlying minification library, installed as a dependency.