Javascript must be used to process HTML elements.

Source: Internet
Author: User

We may often troubleshoot the cause of the problem. In fact, after checking out the redundant loop and streamlining the number of controls, we found that the performance was still not optimistic, So we continued to troubleshoot the problem, an accidental modification greatly improves the efficiency, which is similar to the following:
Before modification:
CopyCodeThe Code is as follows: objdiv. innerhtml + = ' ';

After modification: Copy codeThe Code is as follows: var imga = Document. createelement ("IMG ");
Imga. setattribute ("src", "back.gif ");
Imga. setattribute ("ID", "picture ");
Objdiv. appendchild (imga );

Previously, due to the convenience of writing, we did not use the method of creating page elements, assigning values separately, and finally embedding them. Instead, we directly assigned values to innerhtml using strings, this method is relatively simple and convenient, but it still suffers some losses in terms of performance, because it will inevitably involve a process of converting strings into correct page controls, in this case, the performance loss may be relatively large, resulting in a slow page.

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.