A Script element <script> inserts JavaScript code into an XHTML document. This is one of the two ways to execute JavaScript on our webpages (the other being Event Handler Attributes). The code is executed during page load as it is found (the page is loaded from the top down and left to right). If something occurs, such as an alert then the page stops loading while the code is finishing becuase some code can insert new code into the document (such as the innerHTML and document.write()). Script elements can also be used to define functions, which is typically done in the head.
External JavaScript files
You can link to external files with JavaScript using the script element. It's just like a regular script element except that you add a src attribute and don't put anything in the script element (nothing between the tags). See the example below.
Examples
<script type="text/javascript">
//simple alert() example
alert('Hello there');
</script>