{"library":"rehype-remove-meta-http-equiv","title":"Rehype Plugin to Remove HTTP-Equiv Meta Elements","description":"`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.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install rehype-remove-meta-http-equiv"],"cli":null},"imports":["import rehypeRemoveMetaHttpEquiv from 'rehype-remove-meta-http-equiv'","\"plugins\": [\"rehype-remove-meta-http-equiv\"]","import type { VFile } from 'vfile'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import rehypeParse from 'rehype-parse';\nimport rehypeRemoveMetaHttpEquiv from 'rehype-remove-meta-http-equiv';\nimport rehypeStringify from 'rehype-stringify';\nimport {read} from 'to-vfile';\nimport {unified} from 'unified';\nimport {join} from 'node:path';\nimport {tmpdir} from 'node:os';\nimport {writeFile} from 'node:fs/promises';\n\nasync function processHtml() {\n  const inputHtml = `<!doctype html>\n<html lang=\"en-GB\">\n  <head>\n    <meta charset=\"utf8\">\n    <meta http-equiv=\"content-type\" content=\"text/html; charset=chinese\">\n    <meta http-equiv=\"content-language\" content=\"en-US\">\n  </head>\n  <body>\n    <h1>Hello World</h1>\n    <p>This is a test document to show meta http-equiv removal.</p>\n  </body>\n</html>`;\n\n  // Create a temporary file to simulate reading from a file system\n  const tempFilePath = join(tmpdir(), 'input.html');\n  await writeFile(tempFilePath, inputHtml, 'utf8');\n\n  const file = await unified()\n    .use(rehypeParse, {fragment: false}) // Ensure full document parsing\n    .use(rehypeRemoveMetaHttpEquiv)\n    .use(rehypeStringify)\n    .process(await read(tempFilePath));\n\n  console.log('Original HTML:\\n', inputHtml);\n  console.log('\\nProcessed HTML:\\n', String(file));\n  // Expected output will have the meta http-equiv tags removed.\n}\n\nprocessHtml().catch(console.error);\n","lang":"typescript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}