<script> Attributes: defer
<script> tag has a
defer attribute that mirrors the
defer property of the
defer attribute is a boolean attribute. What this means is it doesn't have a value, it just needs to be present. If the
defer attribute is present, then the script will run after the document has been loaded and parsed and is ready to be manipulated. These scripts run in the order in which they appear in the document (compared to asynchronous scripts which can run out of order).
defer attribute is not present (and neither is a
async attribute), it will run synchronously (the default, also called a blocking script). If a script is running asynchronouly, then it means other things can be running at the same time.
According to the HTML5 standard, the
defer attribute and the
async attribute can only be used when the
src attribute is used. Some browsers may support deferred inline scripts. If both the
defer attributes are present, the browser will use the
async attribute and ignore the