The following function simply returns an of elements with the specified tagname in the document. For some reason on successive calls to the function the execution of it gets slower and slower.. I have tested it thoroughly and the for-loop line in the cause, but I don't understand why that would cause a slow down on successive calls.
function getElementsByTagName2(tagName){
var arr=new Array();
var elems=document.getElementsByTagName(tagName);
for(var i=0, len=elems.length; i!=len; arr.push(elems[i++]));
return arr
}
EDIT: Changed variable names to please user257493.
EDIT1: Just tested jQuery and it has the same issue. The degradation is minor though.