JS Create element

Source: Internet
Author: User

JS creates multiple data and inserts a method into the page.

Method One:

The execution time is about 35ms.

This belongs to the use of string concatenation, once again inserted into the page. The disadvantage is that it is easy to cause events to be difficult to bind.

Method Two:

The execution time is uncertain, the minimum is around 80ms, long to reach 180ms or so.

This method is to create a document fragment to save the nodes that need to be inserted, and then insert them into the page at once.

Method Three:

The execution time is basically maintained at around 80ms.

This method is inserted into the page immediately after each node is created, which frequently results in reflow and repaint of the page. It is not recommended to use this method for Dom read and write.

When using jquery to create a document fragment, the method is similar to JS creation, which requires that the jquery object be converted to a DOM object and then manipulated.

It takes more than 300 milliseconds.

JS Create element

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.