Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Modular HTML minifier, built on top of the PostHTML

License

NotificationsYou must be signed in to change notification settings

maltsev/htmlnano

Repository files navigation

npm versionCI

Modular HTML minifier, built on top of thePostHTML. Inspired bycssnano.

Benchmarks

WebsiteSource (KB)html-minifier-terserhtml-minifier-nexthtmlnanominifyminify-html
stackoverflow.blog1663.3%3.3%8.3%4.6%4.0%
github.com5413.7%3.7%18.1%7.9%6.2%
en.wikipedia.org2204.6%4.6%4.9%6.2%2.9%
npmjs.com4600.5%0.5%0.9%3.6%0.7%
tc39.es71988.5%8.5%8.7%9.5%9.1%
apple.com1907.6%7.6%12.1%10.5%8.1%
w3.org4918.9%18.9%23.0%24.1%19.9%
weather.com17700.2%0.2%12.1%11.9%0.6%
Avg. minify rate5.9%5.9%11.0%9.8%6.4%

Latest benchmarks:https://github.com/maltsev/html-minifiers-benchmark (updated daily).

Documentation

https://htmlnano.netlify.app

Usage

npm install htmlnano
consthtmlnano=require('htmlnano');constoptions={removeEmptyAttributes:false,// Disable the module "removeEmptyAttributes"collapseWhitespace:'conservative'// Pass options to the module "collapseWhitespace"};// posthtml, posthtml-render, and posthtml-parse optionsconstpostHtmlOptions={sync:true,// https://github.com/posthtml/posthtml#usagelowerCaseTags:true,// https://github.com/posthtml/posthtml-parser#optionsquoteAllAttributes:false,// https://github.com/posthtml/posthtml-render#options};htmlnano// "preset" arg might be skipped (see "Presets" section below for more info)// "postHtmlOptions" arg might be skipped.process(html,options,preset,postHtmlOptions).then(function(result){// result.html is minified}).catch(function(err){console.error(err);});

Also, you can use it as CLI tool:

node_modules/.bin/htmlnano --help

More usage examples (PostHTML, Gulp, Webpack):https://htmlnano.netlify.app/next/usage

About

Modular HTML minifier, built on top of the PostHTML

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors25


[8]ページ先頭

©2009-2025 Movatter.jp