Page JS and CSS load order optimization recommendations __JS

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.