hast-util-minify-whitespace is a focused utility within the unified ecosystem, specifically designed to optimize HTML by minifying whitespace between elements in a `hast` (HTML Abstract Syntax Tree). It reduces multiple consecutive whitespace characters to a single space, or to a newline if configured, thereby improving the size of HTML fragments. The package is currently at version 1.0.1, with releases coordinated within the larger `rehypejs` collective, which emphasizes modern JavaScript practices. Key differentiators include its robust integration into the pluggable unified processing pipeline, full TypeScript support, and its commitment to WHATWG HTML parsing standards. It operates as an ESM-only module and requires Node.js 16 or newer, aligning with contemporary Node.js environments.
npm install hast-util-minify-whitespaceVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use `minifyWhitespace` to process a `hast` tree created with `hastscript`, showing the transformation of internal whitespace.
Upgrade your Node.js environment to version 16 or later.
Ensure your project uses ES modules (`import`) and configure your `package.json` with `"type": "module"` or use `.mjs` extensions for files importing this package.
Ensure your build tooling and Node.js environment are up to date and correctly configured to handle the `exports` field. Avoid relying on undocumented subpath imports.
Always use `rehype-sanitize` or a similar sanitization utility on your `hast` tree before serializing it to HTML, especially if the input HTML is untrusted.
Change `const minifyWhitespace = require('hast-util-minify-whitespace')` to `import { minifyWhitespace } from 'hast-util-minify-whitespace'` and ensure your project is configured for ESM.Confirm you are using `import { minifyWhitespace } from 'hast-util-minify-whitespace'` and that your environment supports ESM.Install `hastscript` (`npm install hastscript`) and ensure you `import { h } from 'hastscript'` in your file.No dependency data recorded yet.