Script Tag in HTML

While this tutorial has content that we believe is of great benefit to our community, we have not yet tested or edited it to ensure you have an error-free learning experience. It's on our list, and we're working on it! You can help us out by using the "report an issue" button at the bottom of the tutorial.

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.


Creative Commons License