Adding either the
defer attribute to a
<script> element results in the external script being fetched in parallel to parsing. The difference between these two attributes only manifests once the script has finished loading: A script with the
async attribute interrupts the parser while a script with the
defer attribute waits for the page to finish parsing.
<script> for critical scripts and
<script defer> for non-critical scripts.
Be careful when considering
<script async>. Today it is often used to indicate non-critical scripts, but is inconsistent in being loaded at low priority and executed at high priority.
This content was originally published on https://webplatform.news.