HTML provides the <script> tag in order to put different scripts inside the HTML. The <script> is generally used for JavaScript but can be also used for other scripting languages. The <script> generally contains scripting statements, functions, variables etc.

<script> Tag Attributes

Event the <script> tag is mostly related to the scripts it provides some attributes to set script features. For example async attribute is used to download the specified script file asynchronously which makes the page load faster.

asyncasyncSpecifies that the script is downloaded in parallel to parsing the page, and executed as soon as it is available (before parsing completes) (only for external scripts)
Sets the mode of the request to an HTTP CORS Request
deferdeferSpecifies that the script is downloaded in parallel to parsing the page, and executed after the page has finished parsing (only for external scripts)
integrityfilehashAllows a browser to check the fetched script to ensure that the code is never loaded if the source has been manipulated
Specifies that the script should not be executed in browsers supporting ES2015 modules
Specifies which referrer information to send when fetching a script
srcURLSpecifies the URL of an external script file
typescripttypeSpecifies the media type of the script

<script> Tag Example

The Javascript scripts can be put inside the <script> tags. The <script> tag is used to set the start of the script. The </script> tag is used to express the end of the script. All content between <script> and </script> are interpreted as script and treated different than HTML tags. The type attribute is used to specify the script type. In the following example we set the type attribute as text/JavaScript .


      <title>Script Tag Example</title>

      <script type = "text/JavaScript">
         document.write("You're visiting wisetut!")

Download Script As File

Another usage for the <script> tag is specifying the script file location by using the src attribute. In the following example we load the script from the .


      <title>Script Tag Example</title>

      <script type = "text/JavaScript" src="">

Leave a Comment