In IE9, I went from 1.6 seconds to 0.031 seconds. With Chrome, I switched from 0.302 seconds to 0.018 seconds.
A working example with detach () (the fastest, but will cause layout problems if you delay re-inserting the table, that is, if you allow re-rendering of the page without the table in the DOM).
Working example with a simple DocumentFragment clone
The key is to clone the table as a DocumentFragment (or temporarily remove it from the DOM with detach() and manipulate the cell heights of the cloned table (i.e. before the table is part of the DOM). Height calculations have been performed, replace the original table with the cloned table.
The .height() calculations didn't slow you down, it's the fact that you went through and manipulated the DOM in a big loop. Of the three large browsers, Internet Explorer is the slowest when manipulating the DOM.
For some further reading, some time ago I put together several DOM tests that give a good estimate of the relative performance of the browser with the DOM. John Resig also wrote about using DocumentFragments and DOM manipulations: http://ejohn.org/blog/dom-documentfragments/
source share