Created
February 3, 2019 05:28
-
-
Save Weiyuan-Lane/dbafebaac2959c414f0c5a3f24b311b8 to your computer and use it in GitHub Desktop.
Defer and async script loading example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head></head> | |
<body> | |
<!-- Script loading, parsing and execution after html content below | |
is rendered, or what is known as "DOMContentLoaded" event --> | |
<script src="script_one.js" defer="defer"></script> | |
<!-- Same as above, except it maintains order of execution after | |
"script_one" --> | |
<script src="script_two.js" defer="defer"></script> | |
<!-- Loading doesn't block rendering of DOM elements, but when | |
the script is executed is not deterministic. Best used for | |
independent components --> | |
<script src="script_three.js" async="async"></script> | |
<!-- Rendered in page first --> | |
<p>I'm an alpaca</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment