`hast-util-is-javascript` is a utility package within the unified/rehype ecosystem designed to determine if a given `hast` (HTML Abstract Syntax Tree) node represents a JavaScript script. It specifically checks `<script>` elements, evaluating their `type` and `language` attributes to ascertain if they contain or reference JavaScript, or if these attributes are absent, implying JavaScript by default. The current stable version is `3.0.1`. As part of the `rehypejs` project, it follows a coordinated release schedule, often releasing minor or patch updates across multiple packages, with major version increments for significant breaking changes, such as the recent `7.0.0` ecosystem release which introduced ESM-only modules and a Node.js 16+ requirement. Its primary differentiator is its seamless integration with other `hast` manipulation tools and its strict adherence to WHATWG HTML parsing standards.
npm install hast-util-is-javascriptVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `isJavaScript` to check various `hast` script nodes for JavaScript content based on their `type` or `language` attributes, or when these attributes are implicitly JavaScript.
Migrate your project to use ES module imports (`import ... from '...'`) instead of CommonJS `require()` statements.
Upgrade your Node.js environment to version 16 or newer. Check the unified collective's compatibility guidelines for specific version requirements.
Always sanitize your `hast` trees, especially when dealing with user-generated or untrusted content. Use `rehype-sanitize` to make the tree safe before rendering to HTML.
Change your import statement from `const isJavaScript = require('hast-util-is-javascript')` to `import { isJavaScript } from 'hast-util-is-javascript'`.Ensure you are using a named import: `import { isJavaScript } from 'hast-util-is-javascript'`.No dependency data recorded yet.