Script defer attribute
Definition and Usage
defer
whether the script should be executed when the page parsing is completed.
This attribute reflects <script> tag of defer attribute.
Note:The defer attribute is only applicable to external scripts (and should only be used when setting the src attribute).
Note:There are several ways to execute external scripts:
- If async is present: Execute the script asynchronously with the rest of the page (the script will be executed while the page continues to parse)
- If async is not present and defer is present: Execute the script when the page parsing is completed
- If neither async nor defer is present: Execute the script immediately before the browser continues parsing the page
See also:
HTML Reference Manual:Attribut defer de la balise <script> HTML
HTML Reference Manual:Balise <script> HTML
Example
Determine whether the script was executed when the page parsing was completed:
var x = document.getElementById("myScript").defer
Syntax
Return the defer attribute:
scriptObject.defer
Set the defer attribute:
scriptObject.defer = true|false
attribute value
value | description |
---|---|
true|false |
Définit si le script doit s'exécuter lorsque la page est complètement analysée.
|
Détails techniques
Valeur de retour : | Valeur booléenne, retourne true si le script s'exécute après la fin de l'analyse de la page ; sinon retourne false. |
---|
Support du navigateur
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |