Open In App

HTML | <script> async Attribute

The HTML,<script> async attribute is a boolean attribute. When present, it specifies that the script will be executed asynchronously when it is available. This attribute only works for external scripts (and used only in when src attribute is present ).
Note: There are so many ways in which external script execute: 
 

Syntax: 
 



<script async>

Example: Index.html 
 




<!DOCTYPE html>
<html>
 
<body>
    <center>
        <h1 style="color:green">
          Geeksforgeeks
      </h1>
        <p id="p1">Hello GFG</p>
 
 
        <script src="geeks.js" async></script>
    </center>
</body>
 
</html>

geeks.js 
 






alert("Hello GFG"); 

Output: 
 

Supported Browsers: The browsers supported by HTML <script> async attribute are listed below 
 

 

Article Tags :