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.