From http://www.w3schools.com (Copyright Refsnes Data)

HTML 5 <script> tag


Definition and Usage

Defines a script, such as a JavaScript.


Differences Between HTML 4.01 and HTML 5

HTML 5 has some new attributes, and some HTML 4.01 attributes are no longer supported.


Tips and Notes

Note: There are ways a script can be executed:

The async attribute is "true": The script will be executed asynchrously with the rest of the page, so the script will be executed while the page continues the parsing.

The async attribute is "false", but the defer attribute is "true": The script will be executed when the page is finished with the parsing.

Both the async attribute and the defer attribute is "false": The script will be executed immediately, and the page will wait for the script to finish before continuing the parsing.

Tip: If there is a src attribute, the <script> element must be empty.


Example

Source Output
<script type="text/javascript">
document.write("Hello World!")
</script>
 


Attributes

Attribute Value Description 4 5
async true
false
Defines if the script should be executed asynchronously or not   5
type text/ecmascript
text/javascript
application/ecmascript
application/javascript
text/vbscript
Indicates the MIME type of the script 4 5
charset charset Defines the character encoding used in script. Not supported. 4  
defer true
false
Indicates that the script is not going to generate any document content. The browser can continue parsing and drawing the page 4 5
language javascript
livescript
vbscript
other
Specifies the scripting language. Not supported. Use the type attribute instead. 4  
src URL Defines a URL to a file that contains the script (instead of inserting the script into your HTML document, you can refer to a file that contains the script) 4 5


Try-It-Yourself Demos

Insert a script
How to insert a script into your HTML document.

Work with browsers that do not support scripts
How to handle browsers that do not support scripting.


From http://www.w3schools.com (Copyright Refsnes Data)