-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
40 lines (26 loc) · 1.12 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
---
title: "HTMLScriptElement: async property"
short-title: async
slug: Web/API/HTMLScriptElement/async
page-type: web-api-instance-property
browser-compat: api.HTMLScriptElement.async
---
{{APIRef("HTML DOM")}}
The **`async`** property of the {{domxref("HTMLScriptElement")}} interface is a boolean value that controls how the script should be executed. For classic scripts, if the `async` property is set to `true`, the external script will be fetched in parallel to parsing and evaluated as soon as it is available. For [module scripts](/en-US/docs/Web/JavaScript/Guide/Modules), if the `async` property is set to `true`, the script and all their dependencies will be fetched in parallel to parsing and evaluated as soon as they are available.
It reflects the `async` attribute of the {{HTMLElement("script")}} element.
## Value
A boolean.
## Examples
```html
<script id="el" src="/example.js" async></script>
```
```js
const el = document.getElementById("el");
console.log(el.async); // Output: true
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("HTMLScriptElement.defer")}}