Project: rehypejs/rehype-minify

Package: hast-util-is-javascript@2.0.0

  1. Dependents: 10
  2. hast utility to check if an element is a JavaScript script
  1. util 144
  2. utility 140
  3. unist 127
  4. html 122
  5. hast 73
  6. hast-util 47
  7. javascript 19
  8. script 10


Build Coverage Downloads Size Sponsors Backers Chat

Check if an element is a JavaScript script.


This package is ESM only: Node 12+ is needed to use it and it must be importeded instead of requiredd.


npm install hast-util-is-javascript

This package exports the following identifiers: isJavaScript. There is no default export.


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



Return true if node is a <script> element that has a valid JavaScript type, has no type and a valid JavaScript language, or has neither.


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