scriptscript asyncscript defer
HTML parsingwill be paused on download & executionwill be paused on executionwill not be paused
script executionimmediate after downloadimmediate after downloadafter HTML parsing before DOMContentLoaded
order of executionruns in 'load-first' (downloaded) orderruns in programmed order
use for scriptswhich are independent (eg. Google Analytics)which are dependented on other async or deferred scripts

defer works only for external scripts. It is ignored if there is no src attribute.

Dynamic scripts (added using js):

  • behaves as async
  • can make as defer by setting script.async = false