The difference between 1.children and childnodes
ChildNodes is standard, it returns all child nodes, including element nodes, attribute nodes, text nodes, etc., childNodes (i) supported under Ie6/7/8/sf/op/chrome, not supported under IE9/FF. If you want to take the first HTML child node, here can not use FirstChild, to use NodeType to determine the filter.
Children is a non-standard, it returns a collection of child elements, also under the FF does not support children (i) take the element, want to take the first HTML child node, you can use children[0].
The difference between the body and head of the 2.script tag
Usually put in head is when the page is loaded before the JS code is run, is called to execute, and can guarantee that the script has been loaded before any call.
Usually put in the body is when the page is loaded after the JS code is run, loading is executed, it is often used to generate the content of the page.
The introduction of the JS file in the head, loading the head code is loaded with the JS code, so in the body area calls do not need to load the code, the speed is improved, this difference in the small program is not obvious, in the complex large program is significant.
Whether the JS code is inline or in an out-of-chain file, the download and rendering of the page must stop waiting for the script to complete.
Benefits of introducing external files: Easy to maintain, easy to expand, easy to manage and reuse.
browser in the execution of JS code, can not do other things at the same time, the script tag each occurrence will let the page wait for the parsing and execution of the script, JS code after execution can continue to render the page, which is the characteristics of JS blocking.
3. Load on Demand
On-demand loading, the script is generally downloaded after the execution, if the script library is very large, one-time download is very time-consuming, the traditional solution is to press the function module to write scripts in different files, the page manually add script tag loading the specified content, but there is a disadvantage, The user of a class library needs to know the relationship, order, etc. of each script, but not all class library users can make these clear and error-prone. So many frameworks start to support import directives, and what you want to do with an import function is done, without having to use a heap of script files, or to focus on their dependencies.
On-demand loading can be divided into three modes:
Instant sync on Demand mount (blocking, Jsi,jsvm,dojo). The simplest on-demand mount implementation, implemented by XMLHttpRequest synchronous load script files. However, the problem is that the browser will block the browser when it uses this way to synchronize resources: stop responding to user events and stop the page redraw operation. So, while programming is the simplest, the user experience is the worst.
Asynchronously mounts on demand (no blocking, jsi2.0+). Asynchronous import, the user experience is good, but because the asynchronous feature processing is more troublesome.
Delay synchronization on-demand mount (no blocking, jsi2.0+). JSi a method of synchronizing access to resources via dynamic preload, although also synchronous, without blocking, can be considered as a compromise between ease of use and user experience. The disadvantage is that there is a delay that is not available in the current script tag.
20160108 minor Problems