Registry / devops / hexo-filter-htmlminifier

hexo-filter-htmlminifier

JSON →
library1.0.2jsnpmunverified

A Hexo plugin that minifies output HTML files using HTML Minifier. Current stable version is 1.0.2. This plugin integrates into Hexo's filter system, allowing configuration of HTML minification options such as whitespace collapse, comment removal, and attribute quote removal. It is specifically designed for Hexo static site generators and is not a general-purpose minifier. Alternative standalone minifiers include html-minifier-terser.

npm install hexo-filter-htmlminifier
INSTALL
IMPORT
SIG · HEXO-FILTER-HTMLMI
H
hexo-filter-htmlminifier
devopsjavascriptv1.0.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.

hexo-filter-htmlminifier
npm install hexo-filter-htmlminifier --save
npm install hexo-filter-htmlminifier --save-dev
Installed as a regular dependency (not dev) because it's used during Hexo generation.
Configuration
Add to _config.yml under html_minifier:
Add to _config.yml under hexo_filter_htmlminifier:
The configuration key must be exactly html_minifier (lowercase, underscores).
Priority setting
html_minifier: priority: 10000
html_minifier: priority: 0
Priority should be a high number (e.g., 10000) to ensure it runs after other filters.

Installs the plugin and configures HTML minification options in Hexo's _config.yml file.

npm install hexo-filter-htmlminifier --save # In _config.yml of your Hexo site: html_minifier: collapseWhitespace: true removeComments: true removeRedundantAttributes: true removeScriptTypeAttributes: true removeStyleLinkTypeAttributes: true
Debug
Known issues
gotchaPlugin may conflict with other Hexo filters (e.g., GZip filter) if priority is not set correctly.
fix
Set priority to a high value like 10000 to run after others.
affects: >=0.0.0
gotchaOptions passed must match HTML Minifier's expected inputs; invalid options may cause errors.
fix
Refer to HTML Minifier documentation for valid options.
affects: >=0.0.0
gotchaConfiguration key must be exactly 'html_minifier' (lowercase, underscores), not camelCase or other variations.
fix
Use 'html_minifier:' in _config.yml.
affects: >=0.0.0
deprecatedThe plugin may not receive updates; check compatibility with newer Hexo versions.
fix
Test after Hexo updates; consider alternative plugins like hexo-html-minify if needed.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'html-minifier'
Missing dependency or npm install not run.
fix
Run 'npm install hexo-filter-htmlminifier --save' to install both the plugin and its dependency.
WARN: Skipping unknown option: xxx
An option key in the config is not recognized by HTML Minifier.
fix
Check the spelling of options; refer to HTML Minifier's documentation for supported options.
Hexo filter execution order issue
Other filters (e.g., GZip) running before HTML minification, causing output to not be minified.
fix
Set priority to 10000 or higher in config to ensure this filter runs after others.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
html-minifierrequiredcore dependency for HTML minification
hexorequiredpeer dependency for Hexo filter integration
Agent activity
6 hits · last 30 days
node
6
Resources
hexo-filter-htmlminifier — npm install hexo-filter-htmlminifier · libregistry