`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-equivVerified import paths — ran on the pinned version, not inferred.
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.
Migrate your project to use ECMAScript Modules (ESM) syntax with 'import' statements, or ensure your environment supports ESM.
Upgrade your Node.js runtime to version 16 or later.
Always use `rehype-sanitize` (e.g., `.use(rehypeSanitize)`) in your processing pipeline when dealing with untrusted HTML content to prevent XSS attacks.
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.
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`).Ensure `unified` is imported using `import { unified } from 'unified'` and that you are using a compatible version (unified@^13 for rehype v4.x plugins).Add `"type": "module"` to your `package.json` file or use the `.mjs` file extension for your module file to explicitly enable ESM.