HTML5: async, defer
In HTML5, you can tell browser when to run your JavaScript code. There are 3 possibilities:
<script src="myscript.js"></script>
<script async src="myscript.js"></script>
<script defer src="myscript.js"></script>
① Without “async” or “defer”, browser will run your script immediately, before rendering the elements that's below your script tag.
② With “async” (asynchronous), browser will continue to load the HTML page and render it while the browser load and execute the script at the same time.
③ With “defer”, browser will run your script when the page finished parsing. (not necessary finishing downloading all image files. This is good.)