a simple test on modification Dom Tree
timing by time.js

Code:

window.onload = function() {
	time.start('page load');
	var div = document.getElementById("thediv");
	var i=5000; while(i--){
		div.appendChild(document.createElement("a"));
	}
	time.stop('page load');
	
	time.start('page load 2');
	var div2 = document.getElementById("thediv2");
	var fragment = document.createDocumentFragment();
	var i=5000; while(i--){
		fragment.appendChild(document.createElement("a"));
	}
	div2.appendChild(fragment.cloneNode(true));
	time.stop('page load 2');
	
	time.report();
}

Result: Windows 7 Professional
Firefox 3.6.12
page load: 746ms
page load 2: 371ms

Opera 10.63
page load: 19ms
page load 2: 19ms

IE 8.0.7600.16385
page load: 160ms
page load 2: 152ms

IE 6.0
page load: 140ms
page load 2: 150ms

Advertisements