2015 11th Monday

Source: Internet
Author: User
Today wrote nearly a day code, feel more substantial, but because the majority of the solution is that they know or simply try to do a good job, there is no sense of accomplishment, but in advance to set goals, decisive follow the plan is always right. Reduce repainting to improve performance: 1. Avoid frequent DOM operations on the document, if it is necessary to do so in a off-document way, including but not completely including the following: (1). First remove the element from the document, and then put the element back in place (2) After the modification is complete. Set the display of the element to "none" and modify the display to the original value (3) After the modification is complete. If you need to create multiple DOM nodes, you can use DocumentFragment to join document 2 Once you have created it. Centrally modify the style (1). Modify the attributes (2) on the element style as little as possible. Modify the Style (3) as much as possible by modifying the classname. Use the Csstext property to set the style value 3. Cached layout property values are values for non-reference types in the Layout property (numeric type), and if multiple accesses are required, they can be stored in local variables on a single visit, followed by local variables, to avoid rendering the browser every time the property is read. var width = El.offsetwidth;var ScrollLeft = el.scrollleft; 4. The position of the set element is absolute or fixed when the element's position is static and relative, the element is in the DOM tree structure, and the browser renders the entire page when an operation on the element needs to be re-rendered. Setting the element's position to absolute and fixed allows the element to be detached from the DOM tree structure, and the browser needs to render only that element and the elements below it, to some extent shortening the browser rendering time, This is especially worth considering in today's more and more JavaScript animations.

2015 11th Monday

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.