What does it mean of async and defer in this?
Doubt regarding javascript
what happens when both async and defer is present
It would be undefined behaviour, and should not be done.
- If async is present: The script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing)
- If async is not present and defer is present: The script is executed when the page has finished parsing
- If neither async or defer is present: The script is fetched and executed immediately, before the browser continues parsing the page
You have just copied it from w3 schools site
but i wants to know what happens when both async and defer is used beacuse it used in these lecture?
The defer
attribute may be specified even if the async
attribute is specified, to cause legacy Web browsers that only support defer
(and not async
) to fall back to the defer
behavior instead of the synchronous blocking behavior that is the default.
Source: https://www.w3.org/TR/2011/WD-html5-20110525/scripting-1.html#attr-script-async
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.