Registry / devops / html-minify

html-minify

JSON →
library0.3.2jsnpmunverified

Node.js module to minify HTML, CSS, and JS embedded in markup. Stable version is 0.3.2 (last released 2013-07-08), with no further updates. Uses cssmin for CSS and html-minifier for HTML. Primarily a CLI tool; API supports a single function with limited options. Not recommended for new projects; consider html-minifier-terser or minify instead.

npm install html-minify
INSTALL
IMPORT
SIG · HTML-MINIFY
H
html-minify
devopsjavascriptv0.3.2
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.

htmlminify
const htmlminify = require('html-minify');
import htmlminify from 'html-minify';
This package does not support ESM; CommonJS only.
htmlminify
const htmlminify = require('html-minify');
import { htmlminify } from 'html-minify';
Export is default function, not named.
CLI
htmlminify input.html
npx html-minify input.html
No npx support; must install globally.

Read an HTML file, minify it, and write the result to a new file.

const fs = require('fs'); const htmlminify = require('html-minify'); const html = fs.readFileSync('index.html', 'utf8'); const minified = htmlminify(html); fs.writeFileSync('index.min.html', minified, 'utf8'); console.log('Minified HTML saved.');
Debug
Known issues
deprecatedPackage has not been updated since 2013 and uses outdated dependencies.
fix
Migrate to active packages like html-minifier or minify.
affects: >=0.1.0 <=0.3.2
gotchaThe second argument to htmlminify() is linebreakpos; if omitted, output is single line. Cannot pass an options object.
fix
Use html-minifier for configurable options.
affects: ==0.3.2
gotchaInstalling with npm -g i html-minify (typo 'i' instead of 'install') may fail on some systems.
fix
Use 'npm install -g html-minify' or 'npm i -g html-minify'.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'html-minify'
Package is not installed or used incorrectly with ESM import.
fix
Run 'npm install html-minify' and use require() in CommonJS.
TypeError: htmlminify is not a function
Attempted to import as named export instead of default.
fix
Use const htmlminify = require('html-minify');
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
html-minify — npm install html-minify · libregistry