Optimizing Javascript for IE
A while back I posted articles on memory leaks and how to avoid them (read them! seriously). In the process of learning that lesson, I had to rethink the way I wrote my code a little which was a little painful. Actually, every week or so I realize there’s a better way to do something and when I look at code I wrote a month ago I want to rewrite it.
So this article, is kind of frustrating, as it highlights a level of javascript I’d previously not considered much and, as I think about it now, wish I didn’t have to. Specifically, this article talks about how the IE javascript engine works with IE’s DOM engine and how to avoid expensive namespace lookups. It’s worth reading, but having read it I find the knowledge itself annoying. Maybe this stuff would be easier to write in Assembly…
via ajaxian (of course):
Peter Gurevich and Justin Rogers from Microsoft’s IE team recently wrote a blog entitled ‘IE + JavaScript Performance Recommendations - Part 1‘. It’s an interesting read, containing such tips as:
- Precede your variables with var if you are truly defining them in the current scope
- Cache Variables Whenever Possible
- Cache Function Pointers at all costs
- Cache Function Pointers at all costs
Leave a Reply
You must be logged in to post a comment.