How To Find Slow-down In Javascript In IE6
Solution 1:
Just a tip of what that "something" could be...
String concatenation in IE is (or at least was when I tested) very slow. Opera finished after 0.2s, Firefox after 4.1s and Internet Explorer 7 still hadn’t finished after 20 minutes!!!
Don't do:
for (var i=0, i < 200; i++) { s = s + "something";}
Instead, temporarily use an array, and then join it:
var s=[];
for (var i=0; i < 200; i++) s.push("something");
s=s.join("");
Solution 2:
What I usually do is:
var startTime = new Date();
// Lots of heavy code here
console.log("Processing time: ", new Date() - startTime, " ms");
You can get Firebug lite to get console.log to work across browsers. This gives you an idea about how long any given section of your code takes to execute.
Once you know which is the erring section, you can explore options to fix it.
Solution 3:
Microsoft Script Debugger, also see IEBlog for tips
Solution 4:
The lag could also be from a DOM update. When IE needs to re-render a page due to a DOM change, it can be noticeably slower than Firefox. Typically the cursor will freeze when this happens.
Solution 5:
Given speedy firefox and slow IE, xpath expressions and event handlers (make sure you're getting the right number of calls, not 10x the expected amount) are nice places to insert timers manually.
Post a Comment for "How To Find Slow-down In Javascript In IE6"