UIZE JavaScript Framework

PERFORMANCE TEST: Caching Node References

This test page demonstrates that, in IE, implementing a caching system for references to nodes that will be referenced frequently offers a substantial and compelling performance benefit over simply repeatedly using the document.getElementById method on the node IDs. The difference is striking / alarming in IE, while not significant (using these test numbers) in Firefox or Safari.

In the test, HTML for 1000 DIVs is generated and inserted into the page. Then, an entire loop through all of the node IDs is performed 40 times. In the no caching test, the document.getElementById method is used for every node ID. In the caching test, the document.getElementById method is used only the first time in order to cache the node reference, after which the node reference for each node ID is retrieved from the JavaScript object cache instead.