Module script

Module script 

Source
Expand description

Attribute names for script (<script>) elements.

§Purpose

The <script> element embeds or references executable JavaScript code, enabling client-side scripting and dynamic behavior in web pages.

§Common Attributes

  • src: URL of external script file
  • type: MIME type or module type (“text/javascript”, “module”)
  • async: Load and execute asynchronously
  • defer: Defer execution until document is parsed
  • integrity: Subresource integrity hash for security
  • crossorigin: CORS settings for external scripts

§Example

<script src="script.js"></script>
<script src="script.js" defer></script>
<script src="script.js" async></script>
<script type="module" src="app.js"></script>
<script src="https://cdn.example.com/lib.js"
        integrity="sha384-..."
        crossorigin="anonymous"></script>
<script>
  console.log('Inline JavaScript');
</script>

§WHATWG Specification

Constants§

ASYNC
The async attribute.
CROSSORIGIN
The crossorigin attribute.
DEFER
The defer attribute.
INTEGRITY
The integrity attribute.
NOMODULE
The nomodule attribute.
REFERRERPOLICY
The referrerpolicy attribute.
SRC
The src attribute.
TYPE
The type attribute.