The <script> Element
There are two ways to use the
<script> element directly:
<script> element is interpreted from top to bottom.
The rest of the document content is not loaded and/or displayed until after all of the code
<script> element has been evaluated.
browsers that do not support the
document. Though it may still work, this is no longer needed. The following is an example of this:
The browser sees the string "</script>" as if it were the closing </script> tag, but this problem can be easily avoided by escaping the "/" character:
An external file named example.js is loaded into the document in this example. The file itself need
<script> and closing
</script> tags. Processing of the document is halted until the external
file is interpreted. There is also time taken to download it. One
can omit the closing tag in XHTML documents:
Because it is invalid HTML and won't be handled properly by some browsers, this syntax should not be used in HTML documents.
Much like an
<img> element, the
attribute may be set to a full URI that exists outside the domain on which the HTML document exists.