Skip to content

Instantly share code, notes, and snippets.

@metafeather
Created October 6, 2009 12:29
Show Gist options
  • Save metafeather/202968 to your computer and use it in GitHub Desktop.
Save metafeather/202968 to your computer and use it in GitHub Desktop.
/*
Using as a benchmark the task of iterating over a live collection produced by getElementsByTagName. IE/Win, Gecko and Safari all agree as to the fastest means - use a while loop and store the live collection in a variable:
*/
var i = 0, el, els = document.getElementsByTagName(nodeName);
while (el = els[i++]) {
// [...]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment