1. 13
  1.  

  2. 2

    Considering the pros of defer, there seems to be very little usage for async.

    if you specify both, async takes precedence on modern browsers, while older browsers that support defer but not async will fallback to defer.

    So why would you use async at all? And why do newer browsers even bother to support it?

    1. 7

      There are some (admittedly edge case) scenarios where async is still desirable. For example on the BBC News homepage if we loaded our scripts with defer, a bunch of non-defer third-party scripts would execute first and make the page feel slow. We used async instead, so that parsing isnโ€™t blocked while the script is being fetched but it is blocked once the script is available so we can enhance the page and make it feel complete without having to wait for other scripts to execute first.

      1. 2

        Thanks for writing this, I found very little information online on when to use async is a better choice, I added a bit more information to consider this scenario ๐Ÿ‘๐Ÿผ