Since Mike doesn’t really blog anymore, I figured I would steal his thunder and discuss some of his findings the past week.
We have known this function is slow and have tried to avoid using it, but Prototype itself uses it on some very common functions such as:
Enumerable.*(Basically all of them use
Mike overrode the first two functions to use a regular loop instead of
For a long time, I thought Element.update() just abstracted
element.innerHTML. I was wrong. It calls
evalScripts(). Since we never pass in text containing script tags, we overwrote this function to just use
element.innerHTML. Again, another huge performance enhancement.
Element.update()- Since we have taken out the
evalScripts(), there is really no reason to use this function
Element.setStyle()- As long as you don’t set opacity or float styles, don’t use this function.
Element.addClassName()- If you know an element doesn’t have the class name already, just call
element.className += ' foobar'.