It can be defined anywhere within the webpage. The
<script> element either contains scripting statements, or it points to an external script file through the
|src||It specifies the URL of an external script file.|
|type||It specifies the type of the script.|
|async||It specifies that the script will be executed asynchronously with the webpage. It should only be used with external scripts.|
|defer||It is a boolean value which specify that the script is executed after document has been parsed completely.|
typeattribute was required in HTML 4 but it is optional in HTML 5. There is no need to define the type of the script in HTML 5.
<script> tag can also be used to link an external script file by using
It is recommended to be used within the
<head> tag only.
The external script is very useful when we have to use same script in more than one page. The script can be written in an external file, and then it can be added in any webpage where it is required.
Note: If the updated content is not visible to you please refresh the cookies by pressing CTRL + Shift + R.