Registry / devops / mya-optimizer-html-minifier

mya-optimizer-html-minifier

JSON →
library1.0.0jsnpmunverified

A Mya optimizer plugin that minifies HTML using the popular html-minifier library (kangax/html-minifier). Version 1.0.0 is the current stable release. It integrates seamlessly into Mya build pipelines to reduce HTML file size. Compared to manual HTML minification, this plugin automates the process within the Mya ecosystem, leveraging the full configurability of html-minifier. Minimal dependencies and active maintenance.

npm install mya-optimizer-html-minifier
INSTALL
IMPORT
SIG · MYA-OPTIMIZER-HTML
M
mya-optimizer-html-minifier
devopsjavascriptv1.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.

htmlMinifier
import htmlMinifier from 'mya-optimizer-html-minifier'
const { htmlMinifier } = require('mya-optimizer-html-minifier')
Default export is the plugin function itself.
default
import myaHtmlMinifier from 'mya-optimizer-html-minifier'
import { default as myaHtmlMinifier } from 'mya-optimizer-html-minifier'
Default import works for both ESM and CJS.
MyHtmlMinifier
import MyHtmlMinifier from 'mya-optimizer-html-minifier'
import { MyHtmlMinifier } from 'mya-optimizer-html-minifier'
If you need to refer to the type for TypeScript, you may need to import type separately.

Shows how to import and use the HTML minifier plugin within a Mya optimization pipeline.

import { Mya } from 'mya'; import htmlMinifier from 'mya-optimizer-html-minifier'; const mya = new Mya(); mya.optimize({ plugins: [ htmlMinifier({ removeComments: true, collapseWhitespace: true, minifyJS: true, }) ] }); console.log('HTML minification setup complete.');
Debug
Known issues
gotchaThe plugin does not validate options passed to html-minifier; invalid options may silently be ignored or cause runtime errors.
fix
Ensure all options are valid html-minifier options. Refer to html-minifier documentation.
affects: <=1.0.0
Errors
Common errors & fixes
Cannot find module 'html-minifier'
Missing dependency html-minifier in node_modules.
fix
Run npm install html-minifier --save-dev
TypeError: htmlMinifier is not a function
Incorrect import: using destructed import instead of default import.
fix
Use import htmlMinifier from 'mya-optimizer-html-minifier' (default import).
Error: Plugin must be a function
Calling htmlMinifier() returns a function but the plugin array expects a function.
fix
Ensure that htmlMinifier(options) returns a function and you pass the returned function, not the options object.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
html-minifierrequiredCore library for HTML minification.
myarequiredRequired as peer dependency to function as a Mya plugin.
Agent activity
2 hits · last 30 days
node
2
Resources
mya-optimizer-html-minifier — npm install mya-optimizer-html-minifier · libregistry