2010-05-01 63 views
0

这里是3 css文件(其中一个是仅适用于IE)多个样式表减速到网站多少?

<link rel="stylesheet" href="css/blueprint/screen.css" type="text/css" media="screen, projection"> 
<link rel="stylesheet" href="css/blueprint/print.css" type="text/css" media="print">  
<!--[if lt IE 8]><link rel="stylesheet" href="css/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]--> 

如果我继续鸿沟scree.css到这些CSS在我的网站

现在,这将是6个CSS(一个是仅适用于IE浏览器)

<link rel="stylesheet" href="css/blueprint/reset.css" type="text/css" media="screen, projection"> 
<link rel="stylesheet" href="css/blueprint/grid.css" type="text/css" media="screen, projection"> 
<link rel="stylesheet" href="css/blueprint/typography.css" type="text/css" media="screen, projection"> 
<link rel="stylesheet" href="css/blueprint/forms.css" type="text/css" media="screen, projection"> 
<link rel="stylesheet" href="css/blueprint/print.css" type="text/css" media="print">  
<!--[if lt IE 8]><link rel="stylesheet" href="css/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]--> 

如果我甚至在生产后去网站的方法二。它真的会减慢网站页面加载速度吗?如果是的话多少钱?这3个额外样式表会影响网站性能多少?

回答

6

将它们组合到一个样式表中减少了浏览器加载页面所需的HTTP请求数。但是,在第一次请求样式表之后,假设您正确配置了缓存指令,浏览器应该将其缓存起来,因此后续的页面加载看起来没什么区别。

使用像谷歌的PageSpeed插件或雅虎的YSlow工具来找出什么是实际上导致性能问题,一旦你有大部分网站的到位,和优化重要的事情。在此之前不要担心。

+0

这个答案是点亮的,但我想在这一点上挥动Firebug标志。使用Firebug的Net选项卡,您可以获得每一个资源的非常有用的分解,包括额外的DNS查找开销的指示。在这里获取:https://addons.mozilla.org/en-US/firefox/addon/1843 – 2010-05-01 01:16:09

+0

是的。在知道主要影响因素之前,不要着手解决性能问题。这种特殊的差异是相当小的,但它会加起来超过几百页。 – 2010-05-01 01:21:13

+1

@David Foster:Google PageSpeed和Yahoo YSlow实际上是FireBug *的插件,所以我想我不会明确地提到FireBug本身,因为我提到的那些覆盖了这个,并且加载了更多关于加载时间问题的分析。 – Amber 2010-05-01 01:24:53