How can I optimize for IE?

2019-03-28 06:12发布

问题:

I have a JS-heavy app and it runs slowly in IE. I'm about to spend about a week optimizing for IE, and I'd like some direction about things to try.

I found this thread referencing Drip, which seems useful:

IE and Memory accumulation in Javascript

I'm looking for tips like, "use for loops instead of $.each" as well as architectural best practices that I may not be using.

Libraries I'm using:

  • jQuery
  • Google Maps
  • Facebook JS API
  • KnockoutJS
  • Taffy

Things I'm already doing:

  • using for loops instead of $.each
  • caching jQuery contexts for commonly-referenced DOM elements
  • building HTML using Array.join() vs. string concatenation

Any suggestions?

Thanks!

回答1:

Use a JavaScript Profiler in IE



回答2:

Don't go blindly through your code making trivial improvements like changing $.each() loops to for loops; that's really pointless and someday you'll regret it. Use a profiler because it's a very good bet that most of your problems stem from a very small number of unexpectedly bad pieces of code.

Something like dynaTrace ajax edition are invaluable in situations like this.



回答3:

If it is IE6/7 and "one page" app then minimize the dom manipulation ie. rather do one big replace than hundreds of small changes in a loop.