Document: currentScript property - Web APIs | MDN

Value

A HTMLScriptElement or null.

Examples

This example checks to see if the script is being executed asynchronously:

js

if (document.currentScript.async) {
  console.log("Executing asynchronously");
} else {
  console.log("Executing synchronously");
}

View Live Examples

Specifications

Specification
HTML
# dom-document-currentscript-dev

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.