Scripts
A reference to JavaScript in an external file bears the form
<script type="text/javascript" defer="defer" src="/scripts/scripts.js"></script>
The defer attribute instructs the browser not to attempt to execute the script before the page has been completely loaded. This speeds up load time. /scripts/ points to the virtual directory where you store your script files. Replace scripts.js with the name of your own JavaScript file name.
To embed JavaScript code directly into your web page simply place the code between the script tags thus:
<script type="text/javascript">
...
</script>It is actually possible to leave out the "text/javascript" part - at the expense of strict compliance - and save a few bytes per document. It is possible to put JavaScript directly into the body section of a webpage - once again wrapped in <script>...</script> tags. However, we very strongly deprecate this practice. For ease of page maintenance and to improve reusability, all but the simplest of scripts should be placed in external .js files.
Whenever you create webpages that rely on scripts it is good practice to provide suitable feedback to users who have JavaScript disabled. The <noscript> tag is used for this purpose.