I am trying to optimize a sorted table that I wrote. The bottleneck is in the manipulation of the house. I am currently creating new rows in a table and inserting them every time I sort a table. I am wondering if I can speed up the process by simply rearranging the lines rather than re-creating the nodes. For this to be significant, a dom node reorganization would have to be much faster than creating a node. This is true? thanks, -Morgan
I don’t know if creation or manipulation works faster, but I know that it will be faster if you manipulate the whole table when it is not on the page and then place it on everyone at once. Along these rows, it will probably be slower to rebuild existing rows in place unless the entire table is first deleted from the DOM.
This page assumes that it would be the fastest to clone the current table, manipulate it as you wish, then replace the table with the DOM.
I draw this table about twice as fast using innerHTML, creating all the contents as a string, rather than inserting nodes one at a time.
:
http://www.quirksmode.org/dom/innerhtml.html
, dom dom, - script, dom. , , node, , node, , , , . , b/c , dom, .
http://jsfiddle.net/wheresrhys/2g6Dn/6/
It uses jQuery, therefore it is not a pure standard, and it is probably skewed in other ways. But the result he gives is that moving DOM nodes is about twice as fast as creating and releasing dom nodes every time