This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
IE Development Tips
This page is for tips collected by the community on how IE differs from other browsers. The techniques described here are useful when you are optimizing your code for IE.
Memory Management and memory leaks.
- Memory leaks are a major problem in IE. Memory leaks happen when you keep a reference to a COM object (such as any object from the DOM) that points to some JavaScript that points back to the COM object, directly or indirectly. This is really easy to trigger. The best way to avoid it is to try to let SproutCore hold references to DOM elements for you. Use the view.rootElement property.
- Avoid using the $() or $$() functions from Prototype. These will augment the DOM element (which is slow) and will also sometimes leak memory.
- Be careful when you are declaring methods that act as closures. The following for example will leak memory because the closure references a DOM element:
setupListener: function() {
var el = $$sel('.my-element');
el.onscroll = function() {} ; // This creates a closure that reference the DOM element in el!
};
Writing Performant Code
- Always cache values instead of calling get() over and over. This is generally good practice for all browsers because it makes your code both easier to read and faster, but it is especially important in IE.
// DO THIS:
myMethod: function() {
var content = this.get('content') ;
content.set('firstName', 'Charles');
content.set('lastName', 'Jolley') ;
} ;
// NOT THIS:
myMethod: function() {
this.get('content').set('firstName','Charles') ;
this.get('content').set('lastName', 'Jolley') ;
}
- Cache the length value before for loops, or use a while loop to decrement. Calling somthing.length over and over is expensive in IE.
// DO THIS:
var len = array.length ;
for(var idx=0;idx<len;idx++) { ... }
// OR THIS:
var idx = array.length;
while(--idx >= 0) { ... }
// NOT THIS:
for(var idx=0;idx<array.length;idx++) { ... }
Related Links
- * The JScript Blog * – By the IE team – useful for learning some internals.
- * The IE Blog – More generically IE focused by the IE team.







