简体   繁体   English

我的网站在IE上运行缓慢的主要原因可能是什么?

[英]What are the likely main reasons my website is very slow on IE?

I need to know what can be the main reasons (apart from the basics like grouping CSS selectors, reducing image size, using image sprite etc.) which makes a website slow on Internet Explorer, because my website works fine on the others like FF, chrome etc. 我需要知道什么可能是主要原因(除了对CSS选择器进行分组,减小图像大小,使用图像精灵等基础知识之外),这会使网站在Internet Explorer上变慢,因为我的网站在FF等其他网站上都能正常工作,铬等

  1. Is it the huge use of Javascript framework (ie. jQuery, extjs, prototype)? 它是否大量使用了Javascript框架(即jQuery,extjs,prototype)?
  2. Is it because of the use of plugins based on JS framework? 是因为使用了基于JS框架的插件吗?
  3. Should I use core javascript and remove the use of any js framework? 我应该使用核心javascript并删除任何js框架吗?
  4. Should I try to avoid using jQuery(document).ready()? 我应该避免使用jQuery(document).ready()吗? in case of jQuery framework? 如果是jQuery框架?

Above some of the questions which I know and please answer the questions which I couldn't ask because of lesser knowledge about these. 在我所知道的一些问题之上,请回答由于对这些知识的了解较少而无法提出的问题。

I need to make my website perform well on IE (6,7,8) also please suggest. 我需要使我的网站在IE(6,7,8)上表现良好,也请提出建议。

Thanks 谢谢

It has nothing to do with jQuery. 它与jQuery无关。 The plugins however are hit or miss, and may not be well tested in IE. 但是,这些插件很容易碰到,可能无法在IE中进行良好的测试。 I'd use at your own risk. 我会自担风险。

DOM manipulation is very slow in IE. 在IE中,DOM操作非常缓慢。 using appendChild (or insertRow) to add multiple nodes (say, 100+ for a long list) is much slower than building a string and doing one innerHTML. 使用appendChild(或insertRow)添加多个节点(例如,一个长列表为100+)比构建一个字符串并执行一个innerHTML要慢得多。

You also want to be careful how you access nodes. 您还需要注意如何访问节点。 Devs tend to rely upon jQuery too much and search for nodes via their class names, like: 开发人员往往过于依赖jQuery,并通过其类名搜索节点,例如:

$(".evenRows").hover(doSomething);

IE doesn't have a native way of getting a node by class name, so JQ is looping through the entire document and every single element and checking its class name... which needs to be checked via RegExp because it may look like: IE没有通过类名获取节点的本地方法,因此JQ遍历整个文档和每个单个元素并检查其类名...这需要通过RegExp进行检查,因为它可能类似于:

class="evenRows yellow foo bar"

Finally, in spite of its improvements, IE8 is still using an old rendering engine - the same as IE6. 最后,尽管有所改进,但IE8仍使用旧的渲染引擎-与IE6相同。 Don't go crazy with the animations, and don't expect miracles. 不要对动画发狂,不要期待奇迹。

由于MSIE的默认限制为2个并发连接,因此应尽量减少构建页面所需的请求数(使用css-sprites,将js和css文件合并为一个文件)

While you need to speed things up in IE, you can still use Firebug to look for places, that consume resources. 虽然您需要加快IE的速度,但仍然可以使用Firebug查找消耗资源的位置。

  • Install Yslow and see what it tells you 安装Yslow并查看其内容
  • Run the site under profiler (Yslow or Firebug have one) and look for a bottleneck 在探查器下运行该站点(Yslow或Firebug有一个),并查找瓶颈

It is very difficult to answer general questions like this, but jQuery is unlikely to be the one slowing everything down, just remember to 要回答这样的一般问题非常困难,但是jQuery不太可能成为减慢一切的一种方法,请记住

  • Use IDs as selectors wherever possible — they are the fastest, ie $('#myid') 尽可能使用ID作为选择器-它们是最快的,即$('#myid')
  • Avoid using .class selectors without tagname, ie $('div.myclass') can be ten times faster than $('.myclass') . 避免使用没有标记名的.class选择器,即$('div.myclass')可以比$('.myclass')快十倍。

and so on 等等

More tips for using jQuery to achieve better performance. 使用jQuery获得更好性能的更多技巧

通常,较早版本的IE会比早期版本的IE运行JavaScript慢,因为自那时以来,JavaScript的编译速度已有所提高。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM