Gathering detailed insights and metrics for rehype-remove-comments
Gathering detailed insights and metrics for rehype-remove-comments
Gathering detailed insights and metrics for rehype-remove-comments
Gathering detailed insights and metrics for rehype-remove-comments
npm install rehype-remove-comments
Typescript
Module System
Node Version
NPM Version
rehype-minify-enumerated-attribute@5.0.2
Updated on Feb 19, 2025
7.0.1
Updated on Sep 27, 2024
rehype-minify-whitespace@6.0.1
Updated on Sep 17, 2024
hast-util-minify-whitespace@1.0.0
Updated on Sep 17, 2024
rehype-remove-comments@6.1.0
Updated on Sep 17, 2024
html-enumerated-attributes@1.1.0
Updated on Nov 01, 2023
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
95 Stars
252 Commits
16 Forks
8 Watchers
1 Branches
13 Contributors
Updated on Jun 03, 2025
Latest Version
6.1.1
Package Id
rehype-remove-comments@6.1.1
Unpacked Size
12.05 kB
Size
4.47 kB
File Count
9
NPM Version
10.8.3
Node Version
22.7.0
Published on
Sep 27, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
rehype plugin to remove comments.
This package is a plugin that removes comments. By default it keeps conditional comments, optionally it removes them too.
You can use this plugin when you want to improve the transfer size of HTML documents.
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install rehype-remove-comments
In Deno with esm.sh
:
1import rehypeRemoveComments from 'https://esm.sh/rehype-remove-comments@6'
In browsers with esm.sh
:
1<script type="module"> 2 import rehypeRemoveComments from 'https://esm.sh/rehype-remove-comments@6?bundle' 3</script>
On the API:
1import rehypeParse from 'rehype-parse' 2import rehypeRemoveComments from 'rehype-remove-comments' 3import rehypeStringify from 'rehype-stringify' 4import {read} from 'to-vfile' 5import {unified} from 'unified' 6 7const file = await unified() 8 .use(rehypeParse) 9 .use(rehypeRemoveComments) 10 .use(rehypeStringify) 11 .process(await read('index.html')) 12 13console.log(String(file))
On the CLI:
1rehype input.html --use rehype-remove-comments --output output.html
On the CLI in a config file (here a package.json
):
1 … 2 "rehype": { 3 "plugins": [ 4 … 5+ "rehype-remove-comments", 6 … 7 ] 8 } 9 …
This package exports no identifiers.
The default export is rehypeRemoveComments
.
unified().use(rehypeRemoveComments[, options])
Remove comments.
options
(Options
, optional)
— configurationTransform (Transformer
).
Options
Configuration (TypeScript type).
removeConditional
(boolean
, default: false
)
— remove conditional comments (default: false
); the default is to
leave themtest
(Test
, optional)
— choose which comments to keep (optional)Test
Test a comment (TypeScript type).
value
(string
)
— comment valueWhether to keep the comment (boolean
, optional).
1<!--Hello--> 2<!--[if IE 6]>OK<![endif]-->
1<!--[if IE 6]>OK<![endif]-->
HTML is parsed according to WHATWG HTML (the living standard), which is also followed by all browsers.
The syntax tree used is hast.
This package is fully typed with TypeScript.
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line,
rehype-remove-comments@^6
,
compatible with Node.js 16.
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.
See 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.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
security policy file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- 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 2025-06-30
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