I see from time to time, people use async
and defer
simultanously for same (third-party) scripts. Why one does this? Aren't async
and defer
thought for completely different cases?
It's an old technique for when the async
attribute wasn't well supported (IE supported defer
until IE 10 but not async
, but even then it only supported defer
badly).
Unfortunately it's now bad advice as it means defer
is ignored as per MDN linked in fdomnn-m's comment:
If the attribute is specified with the
async
attribute, the element will act as if only theasync
attribute is specified.
And usually you want the more powerful defer
as opposed to async
.
So people should stop doing this.