English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Referenzhandbuch

Vollständiges Verzeichnis der HTML-Tags

HTML: <script> async-Attribut

Das async-Attribut ist ein boolesches Attribut. Wenn das async-Attribut vorhanden ist, wird angegeben, dass das Skript sofort asynchron ausgeführt wird, wenn es verfügbar ist. Das async-Attribut ist nur für externe Skripte geeignet (sollte nur verwendet werden, wenn das src-Attribut vorhanden ist).

 HTML <script> Tag

Online-Beispiel

Falls das Skript ausgeführt werden kann, wird es asynchron ausgeführt:

<!DOCTYPE html
<html
<head
<title>HTML: <script> async-Attribut - Grundlegendes Tutorial-Netz (oldtoolbag.com)<//title>
</head>
<body
<p id="p1">Hallo Welt!<//p>
<script src="demo_async.js" async></script>
</body>
</html>
Testen Sie es heraus ‹/›

Browserkompatibilität

IEFirefoxOperaChromeSafari

Internet Explorer 10Firefox, Opera, Chrome und Safari unterstützen das async-Attribut.

Note:Internet Explorer 9 and earlier versions do not support the async attribute of the <script> tag.

Definition and Usage

The async attribute is a boolean attribute.

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

Note: The async attribute is only applicable to external scripts (it should only be used when the src attribute exists).

Note: External scripts can be executed in various ways:

  • If there is asynchronous: the script is executed asynchronously with the rest of the page (the script will be executed while the page continues to parse)

  • If there is no asynchronous and there is a delay: execute the script after the page is parsed

  • If there is no asynchronous or delay: immediately get and execute the script before the browser continues to parse the page

HTML 4.01 versus HTML5differences

The async attribute is in HTML5 new attributes.

Differences between HTML and XHTML

In XHTML, attribute abbreviations are prohibited, the async attribute must be defined as <script async="async">.

Syntax

<script async>
 HTML <script> Tag