
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
hast-util-is-javascript
Advanced tools
hast utility to check if an element is a JavaScript script.
This package is a utility to check whether a hast node is a <script> that
contains or references JavaScript.
You can use this package to check whether <script> elements contain or
reference JavaScript or something else.
This package is ESM only. In Node.js (version 16+), install with npm:
npm install hast-util-is-javascript
In Deno with esm.sh:
import {isJavaScript} from 'https://esm.sh/hast-util-is-javascript@3'
In browsers with esm.sh:
<script type="module">
import {isJavaScript} from 'https://esm.sh/hast-util-is-javascript@3?bundle'
</script>
import {h} from 'hastscript'
import {isJavaScript} from 'hast-util-is-javascript'
isJavaScript(h('script')) //=> true
isJavaScript(h('script', {type: 'text/ecmascript'})) //=> true
isJavaScript(h('script', {language: 'ecmascript'})) //=> true
isJavaScript(h('script', {type: 'text/fooscript'})) //=> false
isJavaScript(h('script', {language: 'fooscript'})) //=> false
This package exports the identifier
isJavaScript.
There is no default export.
isJavaScript(node)Check if a node is a <script> that contains or references JavaScript.
Returns true if node is a <script> element that has a valid JavaScript
type, has no type and a valid JavaScript language, or has neither.
node (Node) — node to checkWhether a node is a <script> that contains or references JavaScript
(boolean).
HTML is parsed according to WHATWG HTML (the living standard), which is also followed by all browsers.
The syntax tree used is hast.
This package is fully typed with TypeScript.
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line,
hast-util-is-javascript@^3,
compatible with Node.js 16.
As rehype works on HTML and improper use of HTML can open you up to a
cross-site scripting (XSS) attack, use of rehype can also be unsafe.
Use rehype-sanitize to make the tree safe.
See contributing.md in rehypejs/.github for ways
to get started.
See support.md for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
MIT © Titus Wormer
FAQs
hast utility to check if an element is a JavaScript script
We found that hast-util-is-javascript demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.