When we write the foreground page, we may often use the "javascript+ data" method of generating page elements, but when we have to deal with a large amount of data, resulting in the page needs to show too much control, the page response speed will be straight down.
We may often go to troubleshoot the cause of the problem, in fact, after troubleshooting the redundant loops and streamlining the number of controls, we found that performance is still not optimistic, so continue to troubleshoot, an accidental modification, but greatly improved efficiency, is similar to the following changes:
Before modification:
The code is as follows:
objdiv.innerhtml + = ' ";
After modification:
The code is as follows:
var Imga = document.createelement ("img");
Imga.setattribute ("src", "back.gif");
Imga.setattribute ("id", "picture");
Objdiv.appendchild (IMGA);
Before possible because of the convenience of writing, so did not use to create page elements, and then assign values, and finally nested methods, but directly through the string assignment innerHTML method, this method is relatively simple and convenient, but in terms of performance is still a loss, Because this inevitably involves a process of converting a string to the correct page control, where the performance loss is likely to be large, causing the page to be correspondingly sluggish.
Http://www.jb51.net/article/19442.htm
One way JavaScript must avoid using HTML elements