Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating browser support for defer #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dom.html
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ <h2>21. defer vs async</h2>
<p><strong>Question:</strong> What is defer and async keyword does in a script tag?</p>
<p><strong>Answer:</strong> HTML parser will ignore defer and async keyword for inline script (script that does not have a src attribute). </p>
<p><strong>normal:</strong> When you have a plain script tag (no defer or async keyword), parser will pause parsing, script would be downloaded and exectuted. After that parsing resume.</p>
<p><strong>defer:</strong> defer keyword in the script tag will defer the execution of the script. Hence script will be executed when DOM is available. Important point is, defer is not supported by all major major browsers.</p>
<p><strong>defer:</strong> defer keyword in the script tag will defer the execution of the script. Hence script will be executed when DOM is available. There is good <a href="http://caniuse.com/#search=defer">browser support</a> for it.
<p><strong>async:</strong> If possible, set the execution of the script, asynchronously. <code>async</code> keyword has no effect on inline script.</p>
<img src="images/asyncVsDefer.jpg" alt="">
<p> Image copied from <a href="http://peter.sh/experiments/asynchronous-and-deferred-javascript-execution-explained/">JS script execution</a></p>
Expand Down