Gathering detailed insights and metrics for html-enumerated-attributes
Gathering detailed insights and metrics for html-enumerated-attributes
Gathering detailed insights and metrics for html-enumerated-attributes
Gathering detailed insights and metrics for html-enumerated-attributes
npm install html-enumerated-attributes
7.0.1
Published on 27 Sept 2024
rehype-minify-whitespace@6.0.1
Published on 17 Sept 2024
hast-util-minify-whitespace@1.0.0
Published on 17 Sept 2024
rehype-remove-comments@6.1.0
Published on 17 Sept 2024
html-enumerated-attributes@1.1.0
Published on 01 Nov 2023
7.0.0
Published on 30 Aug 2023
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
90 Stars
249 Commits
16 Forks
9 Watching
1 Branches
13 Contributors
Updated on 29 Sept 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
1.3%
4,112
Compared to previous day
Last week
5.6%
21,679
Compared to previous week
Last month
8.7%
85,145
Compared to previous month
Last year
265.9%
589,941
Compared to previous year
No dependencies detected.
rehype plugins to minify HTML.
This GitHub repository is a monorepo that contains a couple utilities, ±30 plugins, and a preset with good and safe default, to minify HTML:
1<!doctype html> 2<html lang="en-GB"> 3 <head> 4 <meta charset="utf-8"> 5 <meta http-equiv="content-language" content="en-US"> 6 <script src="index.js" type="text/javascript" language="javascript"> 7 alert(true); 8 </script> 9 <link rel="stylesheet" href="index.css" type="text/css"> 10 <title>Foo & bar</title> 11 </head> 12 <body> 13 <h1 class="foo foo">bar bar</h1> 14 <p id="alfred" id="alfred"> <strong>foo</strong> <em>bar</em> </p> 15 <button type="BUTTON" onclick="javascript:return false">Alpha</button> 16 </body> 17</html>
1<!doctypehtml><html lang=en><meta charset=utf8><script src=index.js></script><link href=index.css rel=stylesheet><title>Foo & bar</title><h1 class=foo>bar bar</h1><p id=alfred><strong>foo</strong> <em>bar</em></p><button onclick=return!1 type=button>Alpha</button>
This project is useful when you want to improve the size of HTML documents. It’s particularly useful when you’re already using rehype (and remark?) to process HTML.
Presets are combinations of plugins. One preset is maintained here:
rehype-preset-minify
— preset to minify and mangle HTMLThe following plugins maintained here are included in the above preset.
rehype-minify-attribute-whitespace
rehype-minify-css-style
rehype-minify-enumerated-attribute
rehype-minify-event-handler
rehype-minify-javascript-script
rehype-minify-javascript-url
rehype-minify-json-script
rehype-minify-language
rehype-minify-media-attribute
rehype-minify-meta-color
rehype-minify-meta-content
rehype-minify-style-attribute
rehype-minify-whitespace
rehype-normalize-attribute-value-case
rehype-remove-comments
rehype-remove-duplicate-attribute-values
rehype-remove-empty-attribute
rehype-remove-external-script-content
rehype-remove-meta-http-equiv
rehype-remove-script-type-javascript
rehype-remove-style-type-css
rehype-sort-attribute-values
rehype-sort-attributes
The following plugins are not included in the preset as they are potentially dangerous, can make sites slower in certain cases, or need extra configuration. Read their readmes before using:
rehype-concat-css-style
rehype-concat-javascript
rehype-css-to-top
rehype-javascript-to-bottom
rehype-minify-url
rehype-prevent-favicon-request
Also: pass allowDangerousCharacters
to rehype-stringify
if you trust your content.
Here’s a benchmark comparing the results from html-minifier
and rehype-minify
.
To summarize: differences are negligible, in fact, minifying HTML doesn’t matter
much.
What does matter is using good compressions, such as gzip.
Note: html-minifier
sometimes crashes, such as on amazon.
name | raw | gzip | ||||
---|---|---|---|---|---|---|
original | rehype-minify | html-minifier | original | rehype-minify | html-minifier | |
amazon | 567.85KB | 5.71% | 💥 | 128.65KB | 5.07% | 💥 |
bbc | 531.54KB | 4.70% | 4.58% | 58.09KB | 1.85% | 1.96% |
bootstrap | 33.96KB | 22.36% | 22.82% | 8.12KB | 5.17% | 5.36% |
compat-table | 8.67MB | 16.34% | 16.74% | 275.06KB | 8.26% | 10.06% |
ecmascript | 6.62MB | 10.86% | 11.56% | 789.66KB | 6.39% | 6.60% |
eloquent | 80.08KB | 6.43% | 6.45% | 19.13KB | 1.25% | 1.26% |
github | 233.14KB | 13.39% | 14.51% | 38.86KB | 7.48% | 7.91% |
253.98KB | 3.13% | 3.20% | 80.56KB | 3.64% | 3.63% | |
guardian | 765.54KB | 6.75% | 8.71% | 112.21KB | 3.96% | 4.38% |
html | 12.72MB | 3.15% | 3.19% | 1.85MB | 5.49% | 5.58% |
120.77KB | 32.29% | 32.34% | 14.4KB | 13.99% | 13.91% | |
microsoft | 174.26KB | 22.44% | 34.12% | 26.45KB | 12.96% | 15.45% |
nbc | 1.64MB | 5.94% | 6.28% | 221.08KB | 1.86% | 1.92% |
npm | 27.98KB | 3.03% | 2.61% | 8.28KB | 2.22% | 2.01% |
nytimes | 822.38KB | 11.80% | 11.80% | 137.47KB | 2.71% | 2.72% |
slack | 205.45KB | 4.76% | 4.55% | 49.63KB | 2.06% | 1.98% |
stackoverflow | 169.8KB | 18.64% | 19.10% | 45.4KB | 6.42% | 6.67% |
vice | 337.93KB | 3.48% | 3.22% | 92.58KB | 2.61% | 2.52% |
wikipedia | 768.18KB | 6.08% | 6.76% | 144KB | 1.58% | 1.77% |
total | 34.63MB | 31.9MB | 31.83MB | 4.05MB | 3.85MB | 3.85MB |
Huge differences in results are suspicious and may point to bugs.
💥 — Crash.
Use of rehype-preset-minify
is safe by default if the tree is already safe.
As rehype works on HTML and improper use of HTML can open you up to a
cross-site scripting (XSS) attack, use of rehype can also be unsafe.
Use rehype-sanitize
to make the tree safe.
To further optimize the result disregarding security, use the extra plugins
listed above and pass allowDangerousCharacters
to
rehype-stringify
.
rehype-format
— format HTMLSee contributing.md
in rehypejs/.github
for ways
to get started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
MIT © Titus Wormer
No vulnerabilities found.
Reason
13 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no SAST tool detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More