JavaScript performance talk - must see
Joseph Smarr from Plaxo was holding a talk about High-performance JavaScript: Why Everything You’ve Been Taught Is Wrong. His blog with some background info is here. So many true things and some new things, very interesting to watch if you are interested in tweaking your AJAX app to be performing great.
It was especially interesting to hear one thing that I also found out in my current project, it was “do DOM manipulation off-DOM”. Which means if you are doing some “heavy” DOM manipulation you should ie. copy the DOM element into an absolute positioned element (so that it doesn’t effect all the other elements that are floating around it) and manipulate it there. What I did in this case, was just simply setting visibility to hidden, so I can manipulate and evaluate all the parameters (such as layer size, position, etc. mostly using dojo.corrds()) and when done calculating I simply apply it to the original element. In our case we were resizing fonts to best fit in a box. And it made a noteable difference in performance to make the font size manipulation off-DOM.
Found via Alex’s blog entry on the dojo page, thanks.
Neil Roberts said,
October 17, 2007 at 6:18 pm
I did a lot of performance stuff for dojox.dtl and what I ended up doing for large DOM updates is cloning the node tree I want to work on, and using replaceNode to swap it in. The original tree is no longer beneath the document object, and won’t be rendered. I update that tree, and then swap it back in. It’s fast even with very large trees.