Link to test: http://nontroppo.org/timer/Hixie_DOM.html
The biggest issue I saw was the index testIndex
function which in your screenshot takes just over 8 seconds in IE9. Which is copied below for reference.
function testIndex(div) {
for (var i = 0; i < count; i += 1) {
divs[i] = div.childNodes[count*2 - i*2 - 1];
}
}
Note that divs
is an array with 10000 indexes.
There are quiet a few things going on in this function and I think the slow down happens because browsers other than IE have optimized these types of DOM manipulations and calculation caching. I think part of the problem is that this function, unlike all the others, adds a copy of what it finds to the divs
array. So it crawls the DOM, copies the object it finds to an array. IE has never been terribly fast when crawling the DOM. Try the following and see what the difference is.
function testIndex(div) {
var doublecount = (count*2) -1;
for (var i = 0; i < count; i += 1) {
div.childNodes[doublecount - i*2];
}
}
That may speed things up.
精彩评论