Registry / web-framework / rehype-remove-meta-http-equiv

rehype-remove-meta-http-equiv

JSON →
library4.0.1jsnpmunverified

`rehype-remove-meta-http-equiv` is a rehype plugin designed to optimize HTML output by removing `<meta>` elements that possess the `http-equiv` attribute. Specifically, it targets `content-type` and `content-language` meta tags, which can often be set more efficiently through other means (e.g., `charset` attribute on `<meta>` or `lang` attribute on `<html>`). This package is part of the broader unified ecosystem, focusing on transforming HTML syntax trees (hast). Currently at version 4.0.1, this package, along with other rehype plugins, aligns with the modern JavaScript module system, being ESM-only and requiring Node.js 16 or newer for its operation. Its primary purpose is to help reduce the transfer size of HTML documents, contributing to faster page loads without altering the semantic meaning of the document when alternatives for setting charset or language are present.

npm install rehype-remove-meta-http-equiv
INSTALL
IMPORT
SIG · REHYPE-REMOVE-META
R
rehype-remove-meta-http-equiv
web-frameworkjavascriptv4.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rehypeRemoveMetaHttpEquiv
import rehypeRemoveMetaHttpEquiv from 'rehype-remove-meta-http-equiv'
const rehypeRemoveMetaHttpEquiv = require('rehype-remove-meta-http-equiv')
This package is ESM-only since v4. CommonJS 'require' is not supported.
rehypeRemoveMetaHttpEquiv (CLI config)
"plugins": ["rehype-remove-meta-http-equiv"]
When used in rehype CLI configuration (e.g., package.json or .rehyperc), refer to the plugin by its string name without explicit import.
rehypeRemoveMetaHttpEquiv (Type)
import type { VFile } from 'vfile'
While `rehypeRemoveMetaHttpEquiv` is a function, its usage within the `unified` ecosystem often involves `VFile` for input/output and processing messages. The plugin itself is typed, so TypeScript understands its function signature.

This example demonstrates how to use `rehype-remove-meta-http-equiv` within a unified processing pipeline to strip `http-equiv` meta tags from an HTML document, showing the transformation from input to optimized output.

import rehypeParse from 'rehype-parse'; import rehypeRemoveMetaHttpEquiv from 'rehype-remove-meta-http-equiv'; import rehypeStringify from 'rehype-stringify'; import {read} from 'to-vfile'; import {unified} from 'unified'; import {join} from 'node:path'; import {tmpdir} from 'node:os'; import {writeFile} from 'node:fs/promises'; async function processHtml() { const inputHtml = `<!doctype html> <html lang="en-GB"> <head> <meta charset="utf8"> <meta http-equiv="content-type" content="text/html; charset=chinese"> <meta http-equiv="content-language" content="en-US"> </head> <body> <h1>Hello World</h1> <p>This is a test document to show meta http-equiv removal.</p> </body> </html>`; // Create a temporary file to simulate reading from a file system const tempFilePath = join(tmpdir(), 'input.html'); await writeFile(tempFilePath, inputHtml, 'utf8'); const file = await unified() .use(rehypeParse, {fragment: false}) // Ensure full document parsing .use(rehypeRemoveMetaHttpEquiv) .use(rehypeStringify) .process(await read(tempFilePath)); console.log('Original HTML:\n', inputHtml); console.log('\nProcessed HTML:\n', String(file)); // Expected output will have the meta http-equiv tags removed. } processHtml().catch(console.error);
Debug
Known issues
breakingThis package is ESM-only since version 4. Attempting to use 'require()' will result in an 'ERR_REQUIRE_ESM' error.
fix
Migrate your project to use ECMAScript Modules (ESM) syntax with 'import' statements, or ensure your environment supports ESM.
affects: >=4.0.0
breakingVersion 4.0.0 and above require Node.js 16 or newer. Older Node.js versions are not supported, leading to potential runtime errors or unexpected behavior.
fix
Upgrade your Node.js runtime to version 16 or later.
affects: >=4.0.0
gotchaAs rehype processes HTML, untrusted input combined with improper use can lead to Cross-Site Scripting (XSS) vulnerabilities. This plugin removes meta tags but does not sanitize other HTML content.
fix
Always use `rehype-sanitize` (e.g., `.use(rehypeSanitize)`) in your processing pipeline when dealing with untrusted HTML content to prevent XSS attacks.
affects: >=1.0.0
breakingThe `rehype` ecosystem, including this plugin's compatibility, relies on `unified` v13+ and `hast` v3+. Incompatible versions can cause type errors or runtime failures.
fix
Update your `unified`, `rehype-parse`, and `rehype-stringify` packages to their latest major versions (e.g., `unified@^13`, `rehype-parse@^9`, `rehype-stringify@^10`) to ensure compatibility.
affects: >=4.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module ... not supported. Instead change the require of index.js in ... to a dynamic import() call.
Attempting to import the ESM-only `rehype-remove-meta-http-equiv` package using CommonJS `require()` syntax.
fix
Change your import statement from `const plugin = require('rehype-remove-meta-http-equiv')` to `import plugin from 'rehype-remove-meta-http-equiv'` and ensure your project is configured for ESM (e.g., by adding `"type": "module"` to `package.json`).
TypeError: unified is not a function
The `unified` package was not imported correctly, or an incompatible version is being used (e.g., an older CommonJS `require` of a new ESM `unified`).
fix
Ensure `unified` is imported using `import { unified } from 'unified'` and that you are using a compatible version (unified@^13 for rehype v4.x plugins).
SyntaxError: Cannot use import statement outside a module
You are attempting to use an `import` statement for `rehype-remove-meta-http-equiv` in a file that is being treated as a CommonJS module.
fix
Add `"type": "module"` to your `package.json` file or use the `.mjs` file extension for your module file to explicitly enable ESM.
Upgrade
Version history
4.0.1latest on npm
Audit
Dependencies
unifiedrequiredCore ecosystem dependency for rehype plugins; processes the syntax tree.
Agent activity
2 hits · last 30 days
node
2
Resources
rehype-remove-meta-http-equiv — npm install rehype-remove-meta-http-equiv · libregistry