Page load js step
1, the browser while downloading html pages, while start parsing (ranging downloaded to resolve)
2 encountered <script> tag, pause parsing, handed control of page rendering javascript engine
3, if <script > tag references an external script, first download the execution, direct execution or
4, finished, return control of the rendering engine, continue down parsing html pages
Note:
there are a number of external js file, the browser will download all the while js file, but when the execution of the order will be executed in writing.
When using the <script> embedded JavaScript code, remember not to appear "</ script>" string anywhere in the code.
For example, the browser executes the following error code:
<script type="text/javascript"> function sayHello() { console.log("</script>"); } </script>
The browser will report the following error:
Uncaught SyntaxError: Unexpected token Invalid or
because according to the rules parse embedded code when the browser encounters the string "</ script>", I will say it is the end of </ script> tag .
And we can solve this problem through the escape character, such as:
<script type="text/javascript"> function sayHello() { console.log("<\/script>"); } </script>