Three practical techniques for improving web page performance and improving web page performance

Source: Internet
Author: User

Three practical techniques for improving web page performance and improving web page performance

1,Display attribute settings

Set the elementDisplay: none(The node needs to be reshuffled and re-painted once), 100 operations are performed on the node, and the display is restored (the node needs to be re-painted once ). 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,Visibility: hiddenOnly the re-painting has an effect on the elements, and does not affect the re-arrangement.

 

2,Position: absolute/fixed

The position attribute is absolute orFixedThe overhead of the rearrangement is relatively small, because you do not need 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 or csstext attribute..

// Badvar left = 10; var top = 10; el. style. left = left + "px"; el. style. top = top + "px"; // good el. className + = "theclassname"; // goodel.style.css Text + = "; left:" + left + "px; top:" + top + "px ;";

 

The above reference Ruan Yifeng technology blog: http://www.ruanyifeng.com/blog/2015/09/web-page-performance-in-depth.html

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.