We may often investigate the cause of the problem. In fact, after eliminating redundant loops and reducing the number of controls, we found that the performance was still not optimistic, so we continued to investigate. An accidental modification greatly improved the efficiency, something like The following modifications:
Before modification:
objDiv.innerHTML = '
';
After modification:
var imga = document.createElement("img");
imga .setAttribute("src","back.gif");
imga.setAttribute("id","picture");
objDiv.appendChild(imga);
before Perhaps because of the convenience of writing, we did not use the method of creating page elements, assigning values separately, and finally nesting them. Instead, we directly assigned innerHTML through strings. This method is relatively simple and convenient, but it still has some disadvantages in terms of performance. What is lost, because this must involve a process of converting the string into the correct page control, the performance loss may be relatively large, thus causing the corresponding slowness of the page.