最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I optimize for IE? - Stack Overflow

programmeradmin3浏览0评论

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 monly-referenced DOM elements
  • building HTML using Array.join() vs. string concatenation

Any suggestions?

Thanks!

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 monly-referenced DOM elements
  • building HTML using Array.join() vs. string concatenation

Any suggestions?

Thanks!

Share Improve this question edited May 23, 2017 at 12:25 CommunityBot 11 silver badge asked Nov 22, 2010 at 22:24 marclarmarclar 3,0465 gold badges37 silver badges57 bronze badges 7
  • 1 "building HTML using Array.join() vs. string concatenation" A good idea in almost every JavaScript implementation I've ever seen. – T.J. Crowder Commented Nov 22, 2010 at 22:28
  • 1 Which version of IE is it slow in? The javascript execution in v8 is considerably faster than v7. Version 8 is still slower than FFox. Have a clear goal of what you want to achieve, because there is probably only so much you can do before you hit the wall with IE, if it is still too slow then you will have to look to optimise some other way. – slugster Commented Nov 22, 2010 at 22:30
  • Slow in both IE7 and IE8 (I'm ignoring IE6). Obviously, IE8 is better. In what other way would I optimize? I presume it's the JavaScript that's making things slow, and unfortunately, the app requires a great deal of JS. I'm curious as to how Google gets their JS apps to run as well as they do in IE. – marclar Commented Nov 22, 2010 at 22:36
  • @T.J. – I suppose you meant the former is preferred above the latter? ;) – Marcel Korpel Commented Nov 22, 2010 at 22:42
  • @Marcel: Yes (that was my read of the OP's intent as well, hopefully I'm not mistaken!). :-) – T.J. Crowder Commented Nov 22, 2010 at 22:45
 |  Show 2 more ments

3 Answers 3

Reset to default 8

Use a JavaScript Profiler in IE

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.

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.

发布评论

评论列表(0)

  1. 暂无评论