Three Tips for improving web page performance and improving web page skills

Source: Internet
Author: User

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 ";

 

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.