Making Ajax Applications Scream on the Client
Date : 2008 01 11 Category : Tech & DevelopmentCyra Richardson, Senior Program Manager Lead on the IE team, gave a presentation at MIX 2007 on Making Ajax Applications Scream on the Client.
The scope of the presentation is to show how to speed things up right now, not in the future.
Optimizing Symbol Resolution
How to speed up in a late binding world. Discusses the scope chain from vars to the DOM itself, and how to make sure that you don’t keep running around the chain.
JavaScript Code Inefficiencies
To make string manipulation more effience in IE:
Use local vars Cache strings from IE objects Use Array.join for concatenation(I prefict that array.join will stick around even when it isn’t faster, just like the equivilent in Java land).
Some other thoughts:
Don’t use eval unless you really have too. Instead of parameterized code SWITCH is costly for large sets, consider a hash table wrapped in a try/catch WITH is costly due to symbol lookups everywhere, use manual iterators Don’t use your own get/set accessorsIE Performance Considerations
DOM is expensive in IE, especially due to the generic nature of the platform. Also watch out for layout improvements such as hover CSS style.
HTTP Performance
Simplify and reduce:
Script in on JS file Styles in one CSS file Fewer, smaller, unscaled images Simplify layout Use HTTP compression (lots of detail on cache control)Tools and Techniques
Developer Toolbar Fiddler: HTTP traffic watching Ajax View: New from MS Research. On the fly rewrite the JavaScript and add instrumentation code.