Script Tag in HTML

Here's how to insert an external JavaScript file or some inline JavaScript in your HTML documents.

External script file:

<script src="doStuff.js"></script>

Inline script:

<script>
  // your code here
</script>

Where you insert the JavaScript influences the load order. Essential stuff like jQuery itself is usually placed in the <head> section and stuff that can be loaded last like tracking scripts can usually be right before the closing </body> tag.

type="text/javascript"

type="text/javascript" is optional and unnecessary since HTML5. You’ll see it often in code, but you don’t have to use it in your own code.

✖ Clear

🕵 Search Results

🔎 Searching...