The body of the DOM rendering depends on the head of the external JS loaded.
Based on this principle, the recommendations are as follows:
1, head in the presence of JS, in any case, CSS files can not and the body of the request in parallel.
2, head inside the inline JS to all the external CSS file before the CSS file and body inside the request parallel, otherwise it will jam.
Because inline JS to wait for the head inside all the external CSS loaded after the implementation.
3, outside the joint JS on the page Finally, advanced browser will automatically do optimization.
is generally placed in the body inside the last few lines.
4, long execution of inline JS regardless of place on the page will affect page rendering.
Long executed JS, such as the code that listens for events:
1 |
document.getElementById (' bn '). onclick = function () {alert (1);} |
However, this line of code written to the outside of the JS does not affect.
Reference articles:
Https://developers.google.com/speed/docs/insights/OptimizeCSSDelivery#example
Https://developers.google.com/speed/docs/insights/BlockingJS