A script that will not run until after the page has loaded:
The defer attribute is a boolean attribute.
When present, it specifies that the script is executed when the page has finished parsing.
Note: The defer attribute is only for external scripts (should only be used if the src attribute is present).
Note: There are several ways an external script can be executed:
The numbers in the table specify the first browser version that fully supports the attribute.
Attribute | |||||
---|---|---|---|---|---|
defer | Yes | 10.0 | 3.6 | Yes | 15.0 |
NONE.
In XHTML, attribute minimization is forbidden, and the defer attribute must be defined as <script defer="defer">.