[web] Why is javascript so slow in IE?
Hi, recently I've been playing around with making an element of my upcoming site a bit on the swanky side. Now I haven't used a lot of javascript before so I'm unsure if my approach is totally wrong or if it really is that IE sucks.
Anyway I have a grid (created using tables in IE, DIV elements for every other browser). The user can select multiple grid tiles by clicking on a start tile and clicking on an end tile. As this occurs I update the grid looping through each element in between the start element and the element the mouse is currently over and change the background colour (to highlight the selection).
This all works great in any non IE browser, nice and usable on all the computers I've tried it on. However in IE it is TOTALLY unusable. So I have a few questions:
1) Is there a better way to achieve this functionality?
2) If not can anyone suggest any ways I may be able to improve performance in IE? I mean it's definitely due to all the getElementById calls so maybe a lookup table or something similar?
3) Why is IE so damn slow at executing javascript?
Thanks.
First, it needs to be said that the IE javascript engine is an awful relic. The WebKit (SquirrelFish), Gecko (SpiderMonkey) and Chrome (V8) javascript engines are vastly more performant. So no matter what you do your performance in IE will be degraded compared to most every other browser in existence.<br><br>As for resolving your performance problem, I would strongly suggest using a javascript library like <a href="http://jquery.com/">jQuery</a> (my preferred choice), <a href="http://www.prototypejs.org/">Prototype</a> or <a href="http://mootools.net/">MooTools</a>. For one, you are (mostly) guaranteed cross-platform compatibility that is extraordinarily difficult to achieve using pure DOM manipulation. Moreover, and more importantly, these frameworks are likely to be tuned for optimal performance, in that they will use the best method available to do what you want.
Quote:Original post by errcwI haven't tried jQuery, but I will second errcw on that for Prototype and MooTools. They also greatly simplify a lot of common operations, and should save you a lot of time in implementation and debugging.
As for resolving your performance problem, I would strongly suggest using a javascript library like jQuery (my preferred choice), Prototype or MooTools. For one, you are (mostly) guaranteed cross-platform compatibility that is extraordinarily difficult to achieve using pure DOM manipulation. Moreover, and more importantly, these frameworks are likely to be tuned for optimal performance, in that they will use the best method available to do what you want.
jQuery , Prototype or MooTools these libraries reduces our code but they don't give us a performance hit especially when we have a large dom structure. i think before continuing you should visit this link.
http://blog.creonfx.com/javascript/dojo-vs-jquery-vs-mootools-vs-prototype-performance-comparison
Another reason that javascript works slow on IE is global variables. IE6 garbage collector is really bad so avoid to use global variables if your target is all IE versions.<br>If you are working for ie7. Then these javascript libraries and global variables are not a problem.
http://blog.creonfx.com/javascript/dojo-vs-jquery-vs-mootools-vs-prototype-performance-comparison
Another reason that javascript works slow on IE is global variables. IE6 garbage collector is really bad so avoid to use global variables if your target is all IE versions.<br>If you are working for ie7. Then these javascript libraries and global variables are not a problem.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement