<script> tag in HTML
The <script> tag allows users to insert client-side scripts or data blocks in a document.
Scripts may be designed to provide interactivity, calculate and display values or run animations and other tasks.
Attributes of <script> tag
src attribute in <script> tag
src attribute is be used to add an external scripts file to the current web page.
In the above example, sample.js script file is imported, Click here to see that script file.
async attribute in <script> tag
async attribute instructs the browser to execute the script first, and after completely executing the script the other process starts to load.
In the below example, the <h1> element will appear after closing the alert box.
Example 1 - Without async attribute
In the below example, the <h1> element will appear simultaneously with the alert box.