Three Tips for improving web page performance and improving web page skills
1. Set the display attributeFirst, set the element to display:None(Needs to be re-painted once), Then perform 100 operations on the node, and then restore the display (one re-arrangement and re-painting are required ). In this way, you can use two re-renders to replace up to 100 re-renders. The display attribute of the element is visible only when necessary,Because invisible elements do not affect shuffling and re-painting.. In addition, the visibility: the elements of hidden only have an impact on the re-painting and do not affect the re-arrangement.2. position: absolute/fixedFor an element whose position attribute is absolute or fixed, the overhead of rescheduling is relatively small, because it does not have to consider its impact on other elements. 3,Do not change the style one by one, but change the style one by changing the class.. Sample Code:
// Badvar left = 10; var top = 10; el. style. left = left + "px"; el. style. top = top + "px"; // good el. className + = "theclassname ";