script async attribute
The async attribute on the script element:
- → allows you to specify that the external script linked to the page will be executed asynchronously
- is a specific attribute → can be applied ONLY on the next html element: script
- is optional
!Observations
- async attribute can be specified only if src attribute is present → for external scripts only
- in case async attribute is not supported (e.g. IE9), you can specify the defer attribute also, to defer the execution of the script instead of falling to the default immediate execution that blocks the parsing of the page until the script executes.
Examples
< | attribute | = | "value(s)" | > | ... | </ | >Examples |
---|---|---|---|---|---|---|---|
1. | async | = | "", , async | <src="script.js" async> <⁄ > <src="script.js" async=""> <⁄ > <src="script.js" async="async"> <⁄ > |