Rule 5.--put the style sheet on the head
We found that moving the stylesheet to the head section can improve the loading speed of the interface, so that the page elements can be displayed sequentially. In many browsers, such as IE, the problem with putting stylesheets at the bottom of document is that it prohibits the order of Web content from appearing. The browser prevents the display from redrawing the page elements, and the user sees only the blank pages. Firefox does not block the display, but this means that some page elements may need to be redrawn when the stylesheet is downloaded, which causes flicker problems. The HTML specification explicitly requires that the style sheet be defined in the head, so to avoid blank screen or flicker problems, the best way is to follow the HTML specification and place the stylesheet in the head.
Application: This is often ignored by the performance group, which is often used in conjunction with rule 6 to improve the display accuracy and display rate of the page.
Rule 6--Put the script file at the bottom
As with style files, we need to be aware of the location of the script files. We need to put them at the bottom of the page as much as possible, in order to display sequentially, the other side can achieve the largest parallel download. The browser blocks the display until the stylesheet is downloaded, so we need to put the style sheet in the head section. For scripts, the sequential display of the content behind the script will be blocked, so putting the script as far as possible at the bottom means more content can be displayed quickly. The second problem that the script causes is that it blocks the number of concurrent downloads. The http/1.1 specification recommends that the browser do not have more than 2 concurrent downloads per host. So if you distribute the image files across multiple machines, you can reach more than 2 concurrent downloads. However, when the script file is downloaded, the browser does not start other parallel downloads, or even downloads from other hosts. In some cases, it is not easy to move the script to the bottom. For example, the script uses the Document.Write method to insert the page content. There may also be problems with the domain. In many cases, however, there are some ways to do it. An alternative approach is to use deferred scripting (deferred script). The Defer property indicates that the script does not contain document.write, indicating that the browser engraving continues to display. Unfortunately, Firefox does not support the defer property. In IE, the script may be deferred, but not necessarily the long delay required. But from a different perspective, if the foot instinct is delayed, it can be placed at the bottom.
rule 7--Avoid CSS expressions
CSS expressions are powerful (and dangerous) ways to dynamically set CSS properties. IE, starting from version 5, supports CSS expressions such as backgourd-color:expression (New Date ()). GetHours ()%2? " #B8D4FF ":" #F08A00 "), that is, the background color is toggled every hour. The problem with CSS expressions is that they perform more frequently than most people expect. Expressions are evaluated not only when the page is displayed and resize, but also when the page scrolls, even when the mouse moves on the page. One way to reduce the number of times a CSS expression executes is one-time expression, which is to replace an expression with a definite value when it is first executed. If you must set it dynamically, you can use the event handler function instead. If you must use CSS expressions, keep in mind that they can be executed thousands of thousand of the way, affecting page performance.
Application: Mainly on the dynamic set CSS properties of some JS check, as little as possible the number of CSS expression execution.
14 Rules for performance Improvement (V) (vi) (vii)