The code in that thread is largely based on stuff Mike and Paul have provided (I may have added mistakes of my own, though) but I can’t locate the threads from which I took it.
Calculating width height in script
If you remove the lines
alert ("width: "+theWidth+", height: "+theHeight+", index: "+m+", name: "+theName);
selectLayerByIndex(m,false);
and instead collect the info in an Array for example it should run faster than the corresponding DOM code.
Maybe you should search