- Notifications
You must be signed in to change notification settings - Fork31
Modular HTML minifier, built on top of the PostHTML
License
NotificationsYou must be signed in to change notification settings
maltsev/htmlnano
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Modular HTML minifier, built on top of thePostHTML. Inspired bycssnano.
| Website | Source (KB) | html-minifier-terser | html-minifier-next | htmlnano | minify | minify-html |
|---|---|---|---|---|---|---|
| stackoverflow.blog | 166 | 3.3% | 3.3% | 8.3% | 4.6% | 4.0% |
| github.com | 541 | 3.7% | 3.7% | 18.1% | 7.9% | 6.2% |
| en.wikipedia.org | 220 | 4.6% | 4.6% | 4.9% | 6.2% | 2.9% |
| npmjs.com | 460 | 0.5% | 0.5% | 0.9% | 3.6% | 0.7% |
| tc39.es | 7198 | 8.5% | 8.5% | 8.7% | 9.5% | 9.1% |
| apple.com | 190 | 7.6% | 7.6% | 12.1% | 10.5% | 8.1% |
| w3.org | 49 | 18.9% | 18.9% | 23.0% | 24.1% | 19.9% |
| weather.com | 1770 | 0.2% | 0.2% | 12.1% | 11.9% | 0.6% |
| Avg. minify rate | 5.9% | 5.9% | 11.0% | 9.8% | 6.4% |
Latest benchmarks:https://github.com/maltsev/html-minifiers-benchmark (updated daily).
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
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published