html tutorial - async Attribute in HTML - html5 - html code - html form




Autocomplete attribute in html

Learn html - html tutorial - Autocomplete attribute in html - html examples - html programs

  • The async attribute is said to be a Boolean attribute.
  • The async attribute is used to execute the script asynchronously depends upon its availability.
  • The async attribute only presents with combination of src attribute. Because external script only use async attribute.

Syntax for async attribute in HTML:

<script src="source name" async></script>

Applies To:

Elements Attribute
<script> async

Sample Coding for async Attribute in HTML:

Tryit<!DOCTYPE html>
<html>
    <head>
        <title>Wikitechy async attribute</title>
    </head>
    <body>
        <script src="async_demo.js" async></script>
        <h2>Welcome to Wikitechy!</h2>
    </body>
</html>

Code Explanation for async Attribute in HTML:

async Attribute Code Explanation

  1. src attribute is used to specify the external JavaScript file location as “async_demo.js”.
  2. async attribute is used to set the file parsing “async_demo.js” as asynchronously.

Output for async Attribute in HTML:

async Attribute Output

  1. The output shows the <h2> element (“Welcome to Wikitechy!”) and the alert message (“Hello wikitechy!”). Because the async attribute is set so the contents are loading asynchronously.
  2. async Attribute Output
  3. If the async attribute not set the content loading synchronously so the content of <h2> is not loaded.

Browser Support for async Attribute in HTML:

Yes 10.0 3.6 Yes Yes

Related Searches to async Attribute in html