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

internet explorer 9 - IE9 Javascript slower than IE8 - that's weird! - Stack Overflow

programmeradmin1浏览0评论

I'm having difficulty in explaining why the following code runs slower in IE9 than IE8!

Here's some test code that runs smoothly in about half a second in (latest) FF/Chrome/Safari on OS X, WinXP, and Win7 plus IE7 & 8 on WinXP (for simplicity I removed the tweak that makes it work in IE6).

For some reason I can't explain, it's awful in IE9, slow and clunky. Reducing the time for the setTimeout makes it a bit quicker but no less jerky.

I've tried removing and benchmarking a number of what might be the choke points (Math.min for example ... all with no change.

I'm stumped ... can anyone please point me in the right direction?... preferably one that does not require browser-sniffing?

Here's the test code ...

<div id = 'panel' class='noShow' style='background-color: #aaa;'>
    <div id = 'wrapper' class='slideWrapper'>
        <p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p>
    </div>
</div>


<script type = 'text/javaScript'>

    var e = document.getElementById('panel');
    var w = document.getElementById('wrapper');

    w.style.overflow = 'hidden';                                                
    w.style.height = '1px'; 
    var sh = w.scrollHeight;
    show();
    function show()
    {
        setTimeout(function()
           {
                w.style.height = Math.min(sh, (w.offsetHeight + Math.ceil(sh/15))) + 'px';  
                if(
                     (w.offsetHeight < sh)
                ) 
                {
                    show(e);
                }
                else 
                {
                    w.style.height = 'auto'; 
                }                       
        }, 20); 
    }   
</script>

I'm having difficulty in explaining why the following code runs slower in IE9 than IE8!

Here's some test code that runs smoothly in about half a second in (latest) FF/Chrome/Safari on OS X, WinXP, and Win7 plus IE7 & 8 on WinXP (for simplicity I removed the tweak that makes it work in IE6).

For some reason I can't explain, it's awful in IE9, slow and clunky. Reducing the time for the setTimeout makes it a bit quicker but no less jerky.

I've tried removing and benchmarking a number of what might be the choke points (Math.min for example ... all with no change.

I'm stumped ... can anyone please point me in the right direction?... preferably one that does not require browser-sniffing?

Here's the test code ...

<div id = 'panel' class='noShow' style='background-color: #aaa;'>
    <div id = 'wrapper' class='slideWrapper'>
        <p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p><p>xxxxxxxxxxx</p>
    </div>
</div>


<script type = 'text/javaScript'>

    var e = document.getElementById('panel');
    var w = document.getElementById('wrapper');

    w.style.overflow = 'hidden';                                                
    w.style.height = '1px'; 
    var sh = w.scrollHeight;
    show();
    function show()
    {
        setTimeout(function()
           {
                w.style.height = Math.min(sh, (w.offsetHeight + Math.ceil(sh/15))) + 'px';  
                if(
                     (w.offsetHeight < sh)
                ) 
                {
                    show(e);
                }
                else 
                {
                    w.style.height = 'auto'; 
                }                       
        }, 20); 
    }   
</script>
Share Improve this question asked Apr 8, 2011 at 0:25 GeeBeeGeeBee 511 silver badge2 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

IE9 defaults to software rendering on VMware Virtual Machines (as of 7/8/2011) there is supposed to be a hotfix released in the near future but no timeline is given per this blog post.

Are you running the 64 bit version of IE 9 or the 32 bit version? The 64 bit version is not running Chakra which is the optimized JavaScript engine from the 32 bit version

There are always odd performance variations when running in a virtualized environment. The selection of drivers and how the software offloads the processing will have an impact. Have you tried updating the drivers on your system?

发布评论

评论列表(0)

  1. 暂无评论