Caveat: I have not specifically tested this with IE7, but I am reasonably confident based on what I know about its DOM manipulation model.
Changing CSS properties (whether display: none
or visibility: hidden
or what-have-you) will not affect the performance of DOM manipulation in any version of any browser I've worked with. The primary way to improve the speed of DOM manipulation is to remove the node(s) you will be working with from the document tree, performing your manipulations, and adding them back in. This involves keeping track of their succeeding sibling nodes, if any (for use with insertBefore
), which can become complex if you're working with nodes which are scattered around the document.
One technique I have seen when performing a large number of DOM manipulations all at once is to get a list of the body
element's children, remove them, perform your manipulations (wherever they fall in the document tree), and then reappend the body's child nodes. Depending on how long your DOM manipulations take (which is itself partially dependent on the speed of your visitor's computer!), this can produce a noticeable flicker. This is why sites manipulating content via AJAX will usually replace any temporarily-removed content with a "spinner" or loading screen.