Today I Learned

async vs defer attributes

October 13, 2023

async vs defer twitter

Plain script

The HTML file will be parsed until the script file is hit, at that point parsing will stop and a request will be made to fetch the file. The script will then be executed before parsing is resumed.

Async

async downloads the file during HTML parsing and will pause the HTML parser to execute it when it has finished downloading.

Defer

defer downloads the file during HTML parsing and will only execute it after the parser has completed. defer scripts are also guaranteed to execute in the order that they appear in the document.

Reference

https://www.growingwiththeweb.com/2014/02/async-vs-defer-attributes.html


© 2026 - Written by Vuong Vu. Connect with me on LinkedIn.