No matter what JS is packaged into, and ultimately to the browser to execute the JS are the original, are inseparable from the principle of native JS.
Script tag in HTML to load JS tags, we know that JS can be from the external, local, or internal section of the code, here only to discuss from the external loading, for a web-based data exchange at any time the browser, network requests must be executed asynchronously, The natural JS file generally good asynchronous execution, not easy to cause the UI, but the script tag default loading JS is synchronous, blocking, that is, by default the browser according to the way from top to bottom, from left to right to interpret the execution script, For the synchronization request JS file will cause the JS file download complete before actually rendering the UI, this is very easy to understand. Improve the Web user experience?
1 asynchronously download the JS file, where you can use async inside the script tag to indicate that the file was downloaded asynchronously: <script src= "Xxx.js" async>
2 lazy loading, where the defer keyword is used to indicate that the entire document HTML element is loaded before it starts to download the JS file, but this does not mean that it must occur before or after the document Load event, <script src= "Xxx.js" DEFER> If there are multiple such JS delays loading their
The order is also uncertain, so generally defer used less
3 UI loading complete start loading JS, here is very simple, directly <script src= "Xxx.js" > put to the end of the document can be
Knowledge Points: synchronous, asynchronous
Redo JS Virtuoso First play: script and JS load