Closed dracos closed 10 years ago
LGTM! @dracos, would you link to the jsperf so it’s preserved here?
I've now made one specifically for this function at http://jsperf.com/getelementsbytagname-vs-childnodes-loop. Thanks :)
Excellent, and thank you.
getElementsByTagName() returns all descendants, which means it iterates over children of things you have already discounted. childNodes returns only the immediate children. I think this should be more efficient (jsperf has a comparison of getElementsByTagName/childNodes where the former is 50% slower, and that's just doing a simple lookup, no iteration).