Registry / devops / makestatic-optimize-html

makestatic-optimize-html

JSON →
library1.0.28jsnpmunverified

A plugin for the Makestatic static site compiler that optimizes HTML files using html-minifier. Current stable version is 1.0.28. It is part of the Makestatic ecosystem, providing compression and minification during the build process. Key differentiators: integrates seamlessly with Makestatic's file pipeline; allows per-file and global options for html-minifier. Release cadence is low; last update was in 2017.

npm install makestatic-optimize-html
INSTALL
IMPORT
SIG · MAKESTATIC-OPTIMIZ
M
makestatic-optimize-html
devopsjavascriptv1.0.28
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.

OptimizeHtml
import OptimizeHtml from 'makestatic-optimize-html'
const OptimizeHtml = require('makestatic-optimize-html')
Default import; CommonJS require also works but ESM is recommended.
OptimizeHtml.sources
import OptimizeHtml from 'makestatic-optimize-html'; OptimizeHtml.sources(file, context, options)
const { sources } = require('makestatic-optimize-html')
sources is a prototype method, not a named export. Use instance or class method via OptimizeHtml.
OptimizeHtml.minifier
import OptimizeHtml from 'makestatic-optimize-html'; OptimizeHtml.minifier(file, context, options)
const { minifier } = require('makestatic-optimize-html')
minifier is a static method on OptimizeHtml, not named export.

Demonstrates using OptimizeHtml.minifier to minify an HTML string. Uses Promises.

import OptimizeHtml from 'makestatic-optimize-html'; const file = { content: '<html><head></head><body><p>Hello</p></body></html>', path: 'index.html' }; const context = {}; const options = { removeComments: true, collapseWhitespace: true }; OptimizeHtml.minifier(file, context, options) .then(() => { console.log(file.content); // Output: <html><head></head><body><p>Hello</p></body></html> (minified) }) .catch(err => console.error(err));
Debug
Known issues
gotchaOptions passed to OptimizeHtml.minifier are passed directly to html-minifier; invalid options may cause errors.
fix
Refer to html-minifier documentation for valid options.
affects: *
deprecatedThe package is in maintenance mode; no updates since 2017. It may not work with newer versions of Node.js.
fix
Consider using a more actively maintained alternative like html-minifier-terser directly.
affects: >=1.0.0
gotchaThe .sources method expects the file object to have a content property; otherwise, it will throw or produce no output.
fix
Ensure file.content is a string before calling .sources.
affects: *
Errors
Common errors & fixes
TypeError: OptimizeHtml.minifier is not a function
Importing incorrectly as named export instead of default import.
fix
Use default import: import OptimizeHtml from 'makestatic-optimize-html'
Error: Cannot find module 'makestatic-optimize-html'
Package not installed or typo in import.
fix
Run 'npm install makestatic-optimize-html' and check the import path.
Upgrade
Version history
1.0.28latest on npm
Audit
Dependencies
html-minifierrequiredCore dependency for HTML minification
Agent activity
2 hits · last 30 days
node
2
Resources
makestatic-optimize-html — npm install makestatic-optimize-html · libregistry