Web performance optimization--reducing DOM Operations (III)

Source: Internet
Author: User

    • Reduce the number of DOM
    • Reduce DOM Operations
    • Bulk processing of DOM operations
    • Batch process style modifications
    • Try not to use the Tabel layout
    • Try not to use CSS expressions
    • String with array join
    • CSS Selector optimization

1. Reducing the number of DOM

The lower the number of DOM when HTML is generating the DOM tree, the faster the HTML renders

2. Reduce DOM operations

Every time you manipulate the DOM, you bring repaint and REFOLW.

3. Bulk processing of DOM operations:

Removes the DOM Tree from the element, modifies it, and then puts it back, so it will only be called once repaint or reflow

4. Batch Modify Style

Change classname, or use CSS (), principle and batch processing JS the same

5. Try not to use the Tabel layout

An element in the Tabel is changed, and the entire tabel is reflow.

If it is not, you can set Tabel-layout:auto or tabel-layout:fixed, let the Tabel one line of rendering, limit the rendering range

6. Try not to use CSS expressions

Reflow is triggered once per calculation

7.string joins with array join

Using "+" in JS to stitch strings is less efficient, because each run will open up new memory and generate new string variables, and then assign the stitched string to the new variable. Using arrays is a bit more efficient.

8.css Selector Optimization

Because CSS is parsed from right to left, according to this rule, try to make the right style unique

Web performance optimization--reducing DOM Operations (III)

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.