IE9 Javascript比IE8慢 - 这很奇怪! [英] IE9 Javascript slower than IE8 - that's weird!

查看:84
本文介绍了IE9 Javascript比IE8慢 - 这很奇怪!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难解释为什么以下代码在IE9中运行而不是IE8!

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

这里有一些运行顺畅的测试代码在OS X,WinXP和Win7上的(最新)FF / Chrome / Safari中大约半秒钟加上 IE7& 8在WinXP上(为简单起见,我删除了使它在IE6中工作的调整)。

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).

由于某些原因我无法解释,它在IE9中很糟糕,缓慢而笨重。减少setTimeout的时间会使它更快但不会少于生涩。

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.

我已经尝试删除和基准测试一些可能是阻塞点(Math。例如......所有都没有变化。

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>


推荐答案

IE9默认使用VMware虚拟机上的软件渲染(如2011年7月8日)应该有一个在不久的将来发布的修补程序,但没有给出时间表博客文章

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.

这篇关于IE9 Javascript比IE8慢 - 这很奇怪!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆