<script> elements

Load or run JS code in a menu

Attributes

AttributeValueDescriptionExample
defervoidIf the attribute is present, the loaded script is not executed until the document has finished lodaingdefer
srcfile pathFile path to the script file containing the JS codesrc="script.js"

You can specify either the src attribute to load the script from that file, or write JS code directly inside the <script/> element itself

Examples

<script src="script.js"/>
<script defer src="script.js"/>
<script>
  console.log("Hello, world!")
</script>
<script defer>
  console.log("This script will be ran after the document has finished loading")
</script>