According to MDN:
Async...indicate that the browser should, if possible, execute the script asynchronously
The definition is really vague. So let me phrase my understanding explicitly and please correct me if I am wrong:
My first question is that When I use the keyword async to load a 3rd party script, the browser will continue to parse the DOM elements after the tag while downloading the script via a different thread. I want to know how browsers actually implemented the asychnoronous
.
Is my interpretation correct?
My second question is that When would be a good situation to use async
instead of defer
? (I understand the differences between them, I just don't know when would be the case to use one instead of the other)
Let's say a script I want to include does not have any dependencies and it is not depend upon by other scripts. Why is it recommend to use async
in this case instead of defer
other than the difference in execution timing?