The HTML 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:
- when async is present: The script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing)
- when async is not present and defer is present: The script is executed when the page has finished parsing
- If neither async or defer is present: The script is fetched and executed immediately before the browser continues parsing the page
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 async attribute are listed below
- Google Chrome 4.0
- Firefox 4.0
- Apple Safari 4.0
- Opera 10.5
- Edge
Recommended Posts:
- HTML | async Attribute
- HTML | DOM Script async Property
- Async/Await Function in JavaScript
- JavaScript | async function expression
- Async Hooks in Node.js
- HTML | <html> xmlns Attribute
- HTML | scoped Attribute
- HTML | <th> valign Attribute
- HTML | <col> align Attribute
- HTML | poster Attribute
- HTML | Class Attribute
- HTML | style attribute
- HTML | <area> target Attribute
- HTML | oninvalid Event Attribute
- HTML | <select> autocomplete Attribute
- HTML & CSS | Tabindex attribute & Navigation bars
- HTML | <table> bgcolor Attribute
- HTML | onsubmit Event Attribute
- HTML | onunload Event Attribute
- HTML | srcdoc Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


