W3Schools.com

HTML5 <script> async Attribute

HTML5 script Tag Reference HTML5 <script> tag

Example

A script that will be run asynchronously as soon as it is available:

<script type="text/javascript" src="demo_async.js" async="async"></script>

Try it yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The async attribute is supported in all major browsers, except Internet Explorer.


Definition and Usage

The async attribute is a boolean attribute.

When present, it specifies that the script will be executed asynchronously as soon as it is available.

Note: The async attribute is only for external scripts (and should only be used if the src attribute is present).

Note: There are several ways an external script can be executed:

  • If async="async": The script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing)
  • If async is not present and defer="defer": 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

Differences Between HTML 4.01 and HTML5

The async attribute is new in HTML5.


Syntax

<script async="async">

Note: The async attribute is a boolean attribute, and can be set in the following ways:

  • <script async>
  • <script async="async">
  • <script async="">

HTML5 script Tag Reference HTML5 <script> tag
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Best Website Templates Top CSS Templates
CREATE HTML Websites
EASY WEBSITE BUILDER
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE