Frontend Scrapbook

Notes that make a difference

Async vs defer

By admin

on Tue Aug 25 2020

The async and defer attributes can be added to instruct the browser to load a referenced javascript file in parallel while the HTML is still loading ( async ), and/or to execute the script after the html has finished loading (defer). These attributes and either used independently or together on a script element. IE9 and older lack async support but do support defer, so we can combine the two with defer as fallback.

Async doesn’t guarantee that multiple scripts will execute in the order they’re specified in the page source, while defer does.