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:

  // your code here

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" 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.

  Tweet It

🕵 Search Results

🔎 Searching...

Sponsored by #native_company# — Learn More
#native_title# #native_desc#