Thursday, January 20, 2011

Deadly jQuery Selectors (my naive jQuery programming)

Deadly jQuery Selectors (my naive jQuery programming)


// give me all tags with href or src attribute
*[href],*[src]

//MSIE 8: 20000 ms ;-(
//FF 3.6: 1 ms :-)

// simple fix for this is to use plain old dom:

var uri, uris=[], i, e;
for (es = d().getElementsByTagName("*"), i = es.length; i; ) {
e = es[--i];
uri = e.href || e.src;
if (uri) uris.push(uri);
}
// MSIE 8: 323 ms ;-| not so bad

No comments:

Post a Comment