Super Fast Prototype [javascript]
If your a regular subscriber to my blog (and if you aren’t don’t forget you can subscribe here) you will know that I love Prototype, I was incredibly excited to see that Ajaxian had covered Thierry Schellenbach post about high performace JS apps.
Specifically Thierry has performed some profiling tests on some of the most commonly used prototype functions and has come up with a basic set of rules:
- Beware of $$ and event binding
- Beware of other Prototype methods (reports a 40 times speed different between innerHTML and element.update)
- Write to innerHTML instead of using document.createElement
- Use for loops instead of for in loops
- Use Array.join instead of += on a string
- Cache variables and functions
- Limit the usage of eval
- Limit the usage of Try Catch statements
- When manipulating the DOM copy the element out of DOM change it and stick it back in
Taken from the Ajaxian interpretation.
However these all look good but practically one of prototypes main aims is to reduce the amount of cross browser support a lot of JavaScript functions have. A method such as element.update() may takes 40 times long than element.innerHTML but it doesn’t have all the bugs associated with innerHTML.








Leave A Comment