﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Xixi&#039;s Blog &#187; css</title>
	<atom:link href="http://www.xixis.net/archives/tag/css/feed" rel="self" type="application/rss+xml" />
	<link>http://www.xixis.net</link>
	<description>http://www.xixis.net  &#124;  Eternal Sunshine of the Spotless Mind</description>
	<lastBuildDate>Thu, 12 Jan 2012 06:04:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>浏览器标签选择</title>
		<link>http://www.xixis.net/archives/browser-tab-selected.html</link>
		<comments>http://www.xixis.net/archives/browser-tab-selected.html#comments</comments>
		<pubDate>Fri, 09 Jul 2010 18:46:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[IE]]></category>

		<guid isPermaLink="false">http://www.xixis.net/archives/%e6%b5%8f%e8%a7%88%e5%99%a8%e6%a0%87%e7%ad%be%e9%80%89%e6%8b%a9.html</guid>
		<description><![CDATA[1. &#60;!&#8211;[if !IE]&#62;&#60;!&#8211;&#62; 除IE外都可识别 &#60;!&#8211;&#60;![endif]&#8211;&#62;   2. &#60;!&#8211;[if IE]&#62; 所有的IE可识别 &#60;![endif]&#8211;&#62;    3. &#60;!&#8211;[if IE 5.0]&#62; 只有IE5.0可以识别 &#60;![endif]&#8211;&#62;    4. &#60;!&#8211;[if IE 5]&#62; 仅IE5.0与IE5.5可以识别 &#60;![endif]&#8211;&#62;    5. &#60;!&#8211;[if gt IE 5.0]&#62; IE5.0以及IE5.0以上版本都可以识别 &#60;![endif]&#8211;&#62;    6. &#60;!&#8211;[if IE 6]&#62; 仅IE6可识别 &#60;![endif]&#8211;&#62;    7. &#60;!&#8211;[if lt IE 6]&#62; IE6以及IE6以下版本可识别 &#60;![endif]&#8211;&#62;    8. &#60;!&#8211;[if gte IE 6]&#62; IE6以及IE6以上版本可识别 &#60;![endif]&#8211;&#62;    9. &#60;!&#8211;[if IE 7]&#62; 仅IE7可识别 &#60;![endif]&#8211;&#62;    10. &#60;!&#8211;[if lt IE 7]&#62; IE7以及IE7以下版本可识别 &#60;![endif]&#8211;&#62;   ...]]></description>
			<content:encoded><![CDATA[<p>1. &lt;!&#8211;[if !<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/ie" title="显示IE的所有日志" target="_blank">IE</a></span>]&gt;&lt;!&#8211;&gt; 除<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/ie" title="显示IE的所有日志" target="_blank">IE</a></span>外都可识别 &lt;!&#8211;&lt;![endif]&#8211;&gt;   <br />2. &lt;!&#8211;[if <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/ie" title="显示IE的所有日志" target="_blank">IE</a></span>]&gt; 所有的IE可识别 &lt;![endif]&#8211;&gt;    <br />3. &lt;!&#8211;[if IE 5.0]&gt; 只有IE5.0可以识别 &lt;![endif]&#8211;&gt;    <br />4. &lt;!&#8211;[if IE 5]&gt; 仅IE5.0与IE5.5可以识别 &lt;![endif]&#8211;&gt;    <br />5. &lt;!&#8211;[if gt IE 5.0]&gt; IE5.0以及IE5.0以上版本都可以识别 &lt;![endif]&#8211;&gt;    <br />6. &lt;!&#8211;[if IE 6]&gt; 仅IE6可识别 &lt;![endif]&#8211;&gt;    <br />7. &lt;!&#8211;[if lt IE 6]&gt; IE6以及IE6以下版本可识别 &lt;![endif]&#8211;&gt;    <br />8. &lt;!&#8211;[if gte IE 6]&gt; IE6以及IE6以上版本可识别 &lt;![endif]&#8211;&gt;    <br />9. &lt;!&#8211;[if IE 7]&gt; 仅IE7可识别 &lt;![endif]&#8211;&gt;    <br />10. &lt;!&#8211;[if lt IE 7]&gt; IE7以及IE7以下版本可识别 &lt;![endif]&#8211;&gt;    <br />11. &lt;!&#8211;[if gte IE 7]&gt; IE7以及IE7以上版本可识别 &lt;![endif]&#8211;&gt;</p>
<p> <span id="more-592"></span>
</p>
<p>&lt;!&#8211;[if lte IE 6]&gt;……&lt;![endif]&#8211;&gt;</p>
<p>Ite：less than or equal to意思是小于或等于IE6浏览器，用于IE浏览器的条件注释，常用于CSShack，针对IE的JS等。</p>
<p>在进行WEB标准网页的学习和应用过程中，网页对浏览器的兼容性是经常接触到的一个问题。其中因微软公司的Internet Explorer(简称IE)占据浏览器市场的大半江山，此外还有Firefox、Opera等。需要对这些浏览器进行兼容。</p>
<p>同时，单就IE而言，因IE版本的升级更替，目前浏览者使用的主要停留在 IE5(IE5.5)、IE6和IE7这三个版本中。而这3个版本对于我们制作的WEB标准网页（XHTML+CSS）解释执行的显示状况不尽相同。并且，其他非IE浏览器与IE对某些CSS解释也不一样。所以，通过IE浏览器中的专有条件注释可有针对性的进行相关属性的定义。</p>
<p>条件注释只能用于Explorer 5+ Windows(以下简称IE)(条件注释从IE5开始被支持)。如果你安装了多个IE，条件注释（Conditional comments）将会以最高版本的IE为标准（目前为IE 7）。</p>
<p>条件注释只能在windows Internet Explorer(以下简称IE)下使用，因此我们可以通过条件注释来为IE添加特别的指令。</p>
<p>通俗点，条件注释就是一些if判断，但这些判断不是在脚本里执行的，而是直接在<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/html" title="显示html的所有日志" target="_blank">html</a></span>代码里执行的，比如：</p>
<p>&lt;!&#8211;[if IE]&gt;</p>
<p>这里是正常的<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/html" title="显示html的所有日志" target="_blank">html</a></span>代码</p>
<p>&lt;![endif]&#8211;&gt;</p>
<p>1，条件注释的基本结构和HTML的注释(&lt;!&#8211; &#8211;&gt;)是一样的。因此IE以外的浏览器将会把它们看作是普通的注释而完全忽略它们。</p>
<p>2，IE将会根据if条件来判断是否如解析普通的页面内容一样解析条件注释里的内容。</p>
<p>3，条件注释使用的是HTML的注释结构，因此他们只能使用在HTML文件里，而不能在CSS文件中使用。</p>
<p>可使用如下代码检测当前IE浏览器的版本（注意：在非IE浏览器中是看不到效果的）</p>
<p>&lt;!&#8211;[if IE]&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160; &lt;h1&gt;您正在使用IE浏览器&lt;/h1&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160; &lt;!&#8211;[if IE 5]&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;h2&gt;版本 5&lt;/h2&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160; &lt;![endif]&#8211;&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160; &lt;!&#8211;[if IE 5.0]&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;h2&gt;版本 5.0&lt;/h2&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160; &lt;![endif]&#8211;&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160; &lt;!&#8211;[if IE 5.5]&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;h2&gt;版本 5.5&lt;/h2&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160; &lt;![endif]&#8211;&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160; &lt;!&#8211;[if IE 6]&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;h2&gt;版本 6&lt;/h2&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160; &lt;![endif]&#8211;&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160; &lt;!&#8211;[if IE 7]&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;h2&gt;版本 7&lt;/h2&gt;</p>
<p>&#160;&#160;&#160;&#160;&#160; &lt;![endif]&#8211;&gt;</p>
<p>&lt;![endif]&#8211;&gt;</p>
<p>那如果当前的浏览器是IE，但版本比IE5还低，该怎么办呢，可以使用&lt;!&#8211;[if ls IE 5]&gt;，当然，根据条件注释只能在IE5+的环境之下，所以&lt;!&#8211;[if ls IE 5]&gt;根本不会被执行。</p>
<p>lte：就是Less than or equal to的简写，也就是小于或等于的意思。</p>
<p>lt ：就是Less than的简写，也就是小于的意思。</p>
<p>gte：就是Greater than or equal to的简写，也就是大于或等于的意思。</p>
<p>gt ：就是Greater than的简写，也就是大于的意思。</p>
<p>! ：就是不等于的意思，跟javascript里的不等于判断符相同</p>
<p>Conditional comments属于CSS hack? 条件判断属于CSS hack吗？</p>
<p>严格地说是属于CSS hack。因为就好象其他真正的<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/css" title="显示css的所有日志" target="_blank">css</a></span> hack一样，它使得我们可以给一些浏览器赋予特殊的样式，再则它不依赖于某个浏览器的BUG来控制另外一个浏览器（的样式）。除此之外，条件判断还能用来做一些超出CSS HACK范围的事情(虽然这种情况很少发生)。</p>
<p>因为条件判断不依赖于某个浏览器的hack,而是一个经过深思熟虑的特色功能，所以我相信它是可以被放心地使用的。当然，其他浏览器也有可能支持条件判断（到目前为止还没有），但是看起来，他们应该不会使用如&lt;!&#8211;[if IE]&gt;这样的语法。</p>
<p>应该如何应用条件注释</p>
<p>本文一开始就说明了，因为IE各版本的浏览器对我们制作的WEB标准的页面解释不一样，具体就是对CSS的解释不同，我们为了兼容这些，可运用条件注释来各自定义，最终达到兼容的目的。比如：</p>
<p>&lt;!&#8211; 默认先调用<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/css" title="显示css的所有日志" target="_blank">css</a></span>.<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/css" title="显示css的所有日志" target="_blank">css</a></span>样式表 &#8211;&gt;</p>
<p>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://www.zhmy.com/css.css&quot; /&gt;</p>
<p>&lt;!&#8211;[if IE 7]&gt;</p>
<p>&lt;!&#8211; 如果IE浏览器版是7,调用ie7.css样式表 &#8211;&gt;</p>
<p>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://www.zhmy.com/ie7.css&quot; /&gt;</p>
<p>&lt;![endif]&#8211;&gt;</p>
<p>&lt;!&#8211;[if lte IE 6]&gt;</p>
<p>&lt;!&#8211; 如果IE浏览器版本小于等于6,调用ie.css样式表 &#8211;&gt;</p>
<p>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://www.zhmy.com/ie.css&quot; /&gt;</p>
<p>&lt;![endif]&#8211;&gt;</p>
<p>这其中就区分了IE7和IE6向下的浏览器对CSS的执行，达到兼容的目的。同时，首行默认的css.css还能与其他非IE浏览器实现兼容。</p>
<p>注意：默认的CSS样式应该位于HTML文档的首行，进行条件注释判断的所有内容必须位于该默认样式之后。</p>
<p>比如如下代码，在IE浏览器下执行显示为红色，而在非IE浏览器下显示为黑色。如果把条件注释判断放在首行，则不能实现。该例题很能说明网页对IE浏览器和非IE浏览器间的兼容性问题解决。</p>
<p>&lt;style type=&quot;text/css&quot;&gt;</p>
<p>body{</p>
<p>background-color: #000;</p>
<p>}</p>
<p>&lt;/style&gt;</p>
<p>&lt;!&#8211;[if IE]&gt;</p>
<p>&lt;style type=&quot;text/css&quot;&gt;</p>
<p>body{</p>
<p>background-color: #F00;</p>
<p>}</p>
<p>&lt;/style&gt;</p>
<p>&lt;![endif]&#8211;&gt;</p>
<p>同时，有人会试图使用&lt;!&#8211;[if !IE]&gt;来定义非IE浏览器下的状况，但注意：条件注释只有在IE浏览器下才能执行，这个代码在非IE浏览下非单不是执行该条件下的定义，而是当做注释视而不见。</p>
<p>正常就是默认的样式，对IE浏览器需要特殊处理的，才进行条件注释。</p>
<p>在HTML文件里，而不能在CSS文件中使用。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xixis.net/archives/browser-tab-selected.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>网站优化之&#8212;&#8212;优化CSS</title>
		<link>http://www.xixis.net/archives/the-website-optimizer-optimization-of-css.html</link>
		<comments>http://www.xixis.net/archives/the-website-optimizer-optimization-of-css.html#comments</comments>
		<pubDate>Tue, 02 Mar 2010 17:37:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[原创]]></category>
		<category><![CDATA[网站优化]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[Minify]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.xixis.net/archives/%e7%bd%91%e7%ab%99%e4%bc%98%e5%8c%96%e4%b9%8b%e4%bc%98%e5%8c%96css.html</guid>
		<description><![CDATA[原创文章，转载请声明。
由于DIV+CSS结构使网页打开速度更快，如今，大多数网站都采用这种方式编写html。但与此同时，很少人注意到css文件的大小，以及其效率。很多页面引用了多个css文件，并且css代码冗余严重。这无疑会造成页面加载速度缓慢。
 
现在，我就教大家如何优化CSS，压缩CSS的大小，使网页加载速度更快。
首先第一步就是要将你的多个CSS文件合并。CSS文件越少越好，最好只有1个。这样少一个CSS，就直接减少一个http请求。
合并css的方法有很多，最简单的就是手动将css粘贴到一个文件。如果Css文件繁多而紊乱，可以用Minify进行优化。如果你使用wordpress程序可以使用WP Minify插件，这个就是源自Minify的。此插件可以合并压缩css及js文件。当然也有很多其他插件可以实现其功能。
&#160;
其次，就是要优化CSS代码。原则是最大效用的使用CSS选择器，充分利用可继承属性，尽量简短。
例如：
1.尽量用16位颜色代码表示颜色，如果能用三位颜色代码，尽量使用。比如#000 代替#000000。有时候，用颜色名称会比颜色代码还要简短，也可使用。如grey ,red等。
2.合并所有重复定义属性，a{property:x;property:y;} 合并为a{property:y;} 。
3.Margin，Padding等属性的参数尽量简写。margin:1px 1px 1px 1px; 写为 margin:1px; 或a{margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;} 改为 a{margin:10px;} 
4.0PX改为0。
5.尽量去掉空行。
6.合并背景属性参数。
7.如果可以，去除注释。
8.每一个}前的分号可以去掉。

&#160;
如果嫌以上工作量比较大，可以用这个网站或者这个程序对你的css文件进行优化。
只需要将你的CSS代码或者CSS文件的URL路径放在输入框中，然后选择你的压缩级别，最后点击“Procsss CSS”。你就可以看到，CSS代码现在简洁多了，注释语句没有了，还有一些代码也合并了，颜色代码简写了。前后比较一下你的CSS文件，你就会发现，文件变小了很多。
&#160;
另外，如果你还是不满意的你CSS文件大小的话，我们还可以进一步压缩，但是这样以来就会影响到以后的阅读了。可以用Online YUI Compressor。不但可以压缩CSS，还可以压缩JS，压缩后的文件都会变成一行，它把所有换行的空白都去掉了，这样文件更加小了。如果你以后不再修改CSS了，那么可以使用一下。
&#160;
最后，如果能开启服务器端的压缩功能，一定要开启，如zlib或gzip。
&#160;
如此可将页面加载速度提高数倍。
]]></description>
			<content:encoded><![CDATA[<p>原创文章，转载请声明。</p>
<p>由于DIV+CSS结构使网页打开速度更快，如今，大多数网站都采用这种方式编写html。但与此同时，很少人注意到<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/css" title="显示css的所有日志" target="_blank">css</a></span>文件的大小，以及其效率。很多页面引用了多个<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/css" title="显示css的所有日志" target="_blank">css</a></span>文件，并且css代码冗余严重。这无疑会造成页面加载速度缓慢。</p>
<p> <span id="more-396"></span>
<p>现在，我就教大家如何优化CSS，压缩CSS的大小，使网页加载速度更快。</p>
<p>首先第一步就是要将你的多个CSS文件合并。CSS文件越少越好，最好只有1个。这样少一个CSS，就直接减少一个http请求。</p>
<p>合并css的方法有很多，最简单的就是手动将css粘贴到一个文件。如果Css文件繁多而紊乱，可以用<a href="http://code.google.com/p/minify/" target="_blank">Minify</a>进行优化。如果你使用wordpress程序可以使用<a href="http://omninoggin.com/wordpress-plugins/wp-minify-wordpress-plugin/" target="_blank">WP Minify</a>插件，这个就是源自<a href="http://code.google.com/p/minify/" target="_blank">Minify</a>的。此插件可以合并压缩css及js文件。当然也有很多其他插件可以实现其功能。</p>
<p>&#160;</p>
<p>其次，就是要优化CSS代码。原则是最大效用的使用CSS选择器，充分利用可继承属性，尽量简短。</p>
<p>例如：</p>
<blockquote><p>1.尽量用16位颜色代码表示颜色，如果能用三位颜色代码，尽量使用。比如#000 代替#000000。有时候，用颜色名称会比颜色代码还要简短，也可使用。如grey ,red等。</p>
<p>2.合并所有重复定义属性，a{property:x;property:y;} 合并为a{property:y;} 。</p>
<p>3.Margin，Padding等属性的参数尽量简写。margin:1px 1px 1px 1px; 写为 margin:1px; 或a{margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;} 改为 a{margin:10px;} </p>
<p>4.0PX改为0。</p>
<p>5.尽量去掉空行。</p>
<p>6.合并背景属性参数。</p>
<p>7.如果可以，去除注释。</p>
<p>8.每一个}前的分号可以去掉。</p>
</blockquote>
<p>&#160;</p>
<p>如果嫌以上工作量比较大，可以用<a href="http://www.cleancss.com/" target="_blank">这个网站</a>或者<a href="http://csstidy.sourceforge.net/" target="_blank">这个程序</a>对你的css文件进行优化。</p>
<p>只需要将你的CSS代码或者CSS文件的URL路径放在输入框中，然后选择你的压缩级别，最后点击“Procsss CSS”。你就可以看到，CSS代码现在简洁多了，注释语句没有了，还有一些代码也合并了，颜色代码简写了。前后比较一下你的CSS文件，你就会发现，文件变小了很多。</p>
<p>&#160;</p>
<p>另外，如果你还是不满意的你CSS文件大小的话，我们还可以进一步压缩，但是这样以来就会影响到以后的阅读了。可以用<a href="http://www.refresh-sf.com/yui/" target="_blank">Online YUI Compressor</a>。不但可以压缩CSS，还可以压缩JS，压缩后的文件都会变成一行，它把所有换行的空白都去掉了，这样文件更加小了。如果你以后不再修改CSS了，那么可以使用一下。</p>
<p>&#160;</p>
<p>最后，如果能开启服务器端的压缩功能，一定要开启，如zlib或gzip。</p>
<p>&#160;</p>
<p>如此可将页面加载速度提高数倍。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xixis.net/archives/the-website-optimizer-optimization-of-css.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wordpress 提速之 Gzip 压缩</title>
		<link>http://www.xixis.net/archives/wordpress-speed-of-gzip-compression.html</link>
		<comments>http://www.xixis.net/archives/wordpress-speed-of-gzip-compression.html#comments</comments>
		<pubDate>Sun, 07 Feb 2010 14:29:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.xixis.net/?p=304</guid>
		<description><![CDATA[今天来聊下 wordpress 提速，其实关于这方面的话题网上其实蛮多的，速度对一个网站来说无疑是非常重要的，对于速度的追求也是无止境的，在这方面的表率无疑就是 shawn 了，看他博客的很多技巧都是针对速度来的……不过话说回来，速度也不是绝对的，看很多优秀的博客速度并不占优，有时候追求速度难免还会牺牲一些其它的东西！！此文仅供参考。
废话少说，关于 wordpress 的提速还是可以从很多方面入手的，因为 WP 的灵活而导致其效率和速度的下降，比如因为使用插件而在头部载入的 N 多的 JS 和 CSS 就是最为典型的，就不展开说了，今天我们只说 Gzip！
什么是 Gzip 压缩，为什么要用 Gzip 压缩
说白了就是一种压缩的技术，它将浏览器请求的文件在服务器端进行压缩，然后将文件以压缩的形式传递给浏览器，然后在浏览器端进行解压缩，还原后进行解析。而目前 99% 的浏览器都支持 Gzip ，包括 IE 4+, Netscape 4+, Opera 5+ 和所有版本的 Safari 和 Firefox ，所以大家可以放心使用。
在这里我们的压缩对象是所有的 html、JS、和 CSS 。而他的压缩效率惊人，能减小 60% 到70%。像我的博客一个 10K 的 JS 文件，用 Gzip 压缩后浏览器接收的只有 3K 大小，16K 的 CSS 文件也被压缩到了 5K，很强大吧！
怎么知道我的页面是否 Gzip 压缩过了
Gzip 的方法有很多种，而有很多的服务器是默认开启 Gzip 压缩的，不过据我所知，这种服务器少之又少。怎么确定自己的网页是否被 Gzip 呢！！这种测试的网站网上也很多，不过一般只能测试 html，这里推荐给大家一个测试的网站：Websiteoptimization，输入网址后，输入验证码，就会给出你的 Web Page Speed Report.
貌似很多的“童鞋”看错了，现在补图上来！！其中在下面的 Page Objects 中，会给出所有所加载的文件的信息。在最后一栏的信息中，如果显示：Congratulations! This file was compressed. 说明是被压缩过的，如果是：Up to **** bytes could have been saved through compression，显然是还没被压缩的。
启用 Gzip 的几种方法
是的，有几种方法，是针对不同的情况的。
1、最好的情况是你的主机采用的是 Apache 2，并安装启用了mod_deflate 模块。这样就很简单了，只需要在 .htaccess 文件中加入以下代码可以压缩 HTML, PHP, ...]]></description>
			<content:encoded><![CDATA[<p>今天来聊下 wordpress 提速，其实关于这方面的话题网上其实蛮多的，速度对一个网站来说无疑是非常重要的，对于速度的追求也是无止境的，在这方面的表率无疑就是 <a href="http://ishawn.net/">shawn</a> 了，看他博客的很多技巧都是针对速度来的……不过话说回来，速度也不是绝对的，看很多优秀的博客速度并不占优，有时候追求速度难免还会牺牲一些其它的东西！！此文仅供参考。<span id="more-304"></span></p>
<p>废话少说，关于 wordpress 的提速还是可以从很多方面入手的，因为 WP 的灵活而导致其效率和速度的下降，比如因为使用插件而在头部载入的 N 多的 JS 和 CSS 就是最为典型的，就不展开说了，今天我们只说 Gzip！</p>
<h3>什么是 Gzip 压缩，为什么要用 Gzip 压缩</h3>
<p>说白了就是一种压缩的技术，它将浏览器请求的文件在服务器端进行压缩，然后将文件以压缩的形式传递给浏览器，然后在浏览器端进行解压缩，还原后进行解析。而目前 99% 的浏览器都支持 Gzip ，包括 IE 4+, Netscape 4+, Opera 5+ 和所有版本的 Safari 和 Firefox ，所以大家可以放心使用。</p>
<p><strong>在这里我们的压缩对象是所有的 html、JS、和 CSS 。而他的压缩效率惊人，能减小 60% 到70%。像我的博客一个 10K 的 JS 文件，用 Gzip 压缩后浏览器接收的只有 3K 大小，16K 的 CSS 文件也被压缩到了 5K，很强大吧！</strong></p>
<h3>怎么知道我的页面是否 Gzip 压缩过了</h3>
<p>Gzip 的方法有很多种，而有很多的服务器是默认开启 Gzip 压缩的，不过据我所知，这种服务器少之又少。怎么确定自己的网页是否被 Gzip 呢！！这种测试的网站网上也很多，不过一般只能测试 html，这里推荐给大家一个测试的网站：<a href="http://www.websiteoptimization.com/services/analyze/">Websiteoptimization</a>，输入网址后，输入验证码，就会给出你的 Web Page Speed Report.</p>
<p>貌似很多的“童鞋”看错了，现在补图上来！！其中在下面的 Page Objects 中，会给出所有所加载的文件的信息。在最后一栏的信息中，<strong>如果显示：Congratulations! This file was compressed. 说明是被压缩过的，如果是：Up to **** bytes could have been saved through compression，显然是还没被压缩的。</strong></p>
<h3>启用 Gzip 的几种方法</h3>
<p>是的，有几种方法，是针对不同的情况的。</p>
<p>1、最好的情况是你的主机采用的是 Apache 2，并安装启用了mod_deflate 模块。这样就很简单了，只需要在 .<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/htaccess" title="显示htaccess的所有日志" target="_blank">htaccess</a></span> 文件中加入以下代码可以压缩 HTML, PHP, JS, CSS, XML 后缀的文件。</p>
<blockquote><p>&lt;ifmodule mod_deflate.c&gt;</p>
<p>AddOutputFilterByType DEFLATE text/html text/<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/css" title="显示css的所有日志" target="_blank">css</a></span> text/plain text/xml application/x-httpd-php application/x-<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/javascript" title="显示javascript的所有日志" target="_blank">javascript</a></span></p>
<p>&lt;/ifmodule&gt;</p></blockquote>
<p>不过一般的主机都没有这个模块，如果你是独立主机可以自行配置。至于如何检测自己的主机是否有安装这个模块，我还真没找到办法，望高手指点。如果大家有兴趣，可能将上面的代码加好，看是否 Gzip 来试一下！以上方法来自：<a href="http://fairyfish.net/2008/04/07/gzip/">我爱水煮鱼</a></p>
<p>2、用 PHP 来压缩</p>
<p>此方法也需要 PHP 模块 zlib 的支持，不过这是一个基本的模块，一般都开启了！！所以我们主要讲下这部分。</p>
<h3>用 PHP 压缩动态页面</h3>
<p>我们先来看所谓的 html 的压缩，其实也就是由 PHP 动态生成的 html 。这样的方法有很多，我用的是 <a href="http://ishawn.net/tips/enable-gzip-function-of-hostgator.html">shawn 的方法</a> ，还有 <a href="http://wmrpd.com/blog/?p=300">几种方法</a> 供参考。</p>
<h3>用 PHP 压缩 JS 和CSS</h3>
<p><strong>关于 JS 和 CSS 的压缩也有几种方法，目前比较多的是像 K2 学习，将 JS 和 CSS 改为 .php 的方法</strong>。这个前辈已经介绍过了，请移步：<a href="http://sexywp.com/simple-guide-to-css-js-compress.htm">简述对WP博客样式表和JS脚本的压缩</a></p>
<p>这种方法的缺点是要修改每个 JS 和 CSS 文件，有点不太方便。对于将所有插件中的 JS 和CSS 都合并的博客来说还算容易，但没有合并的来说无疑是一项巨大的工程，而且插件更新也是件麻烦的事。另外看着好好的 CSS 文件变成了 PHP ，看着挺怪的，呵呵！！好处是有好的适应性，因为这 K2 用的方法！</p>
<p><strong>第二种方法是老N提供的方法</strong>：<a href="http://neolee.cn/wordpress/compress-js-css/">加速blog，压缩js,css，减省带宽</a> ，这种方法应该说比较简单，而且默认对所有的 JS 和 CSS 生效。原理就是把 JS 和 CSS 利用 .<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/htaccess" title="显示htaccess的所有日志" target="_blank">htaccess</a></span> 交给一个 PHP 文件来处理进行压缩。</p>
<p>老N那的代码貌似复制出来有些问题，我再贴一下，呵呵：</p>
<blockquote><p>1、创建 <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/gzip" title="显示gzip的所有日志" target="_blank">gzip</a></span>.php 文件并上传到博客根目录，代码如下：</p>
<p>下载: <a href="http://www.xiaorsz.com/wp-content/plugins/coolcode/coolcode.php?p=632&amp;download=gzip.php">gzip.php</a></p></blockquote>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;!--</span>p  <span style="color: #000088;">$allowed</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>  <span style="color: #0000ff;">'<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/css" title="显示css的所有日志" target="_blank">css</a></span>'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'text/css'</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">'js'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'text/<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/javascript" title="显示javascript的所有日志" target="_blank">javascript</a></span>'</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">'html'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'text/html'</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">'htm'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'text/html'</span><span style="color: #339933;">,</span>  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>  <span style="color: #000088;">$extension</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #000088;">$extension</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_pop</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$extension</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$allowed</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$extension</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>  <span style="color: #000088;">$pos</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'..'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pos</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #990000;">is_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>  <span style="color: #339933;">@</span><span style="color: #990000;">ob_start</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ob_gzhandler'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Content<span style="color: #339933;">-</span>type<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><span style="color: #000088;">$allowed</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$extension</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> charset<span style="color: #339933;">:</span> UTF<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #990000;">readfile</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>  <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTTP/1.1 404 Not Found'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #009900;">&#125;</span>  <span style="color: #009900;">&#125;</span> <span style="color: #339933;">--&gt;</span></pre></div></div>

<blockquote><p>2、更改.<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/htaccess" title="显示htaccess的所有日志" target="_blank">htaccess</a></span>文件，在.htaccess中添加：</p>
<p>RewriteCond %{REQUEST_FILENAME} -f</p>
<p>RewriteCond %{REQUEST_FILENAME} ^.*\.(css|js|html|htm)$</p>
<p>RewriteRule ^(.*)$ <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/gzip" title="显示gzip的所有日志" target="_blank">gzip</a></span>.php?url=$1 [QSA,L]</p>
<p>就 OK 了~，的确很简单</p></blockquote>
<p>但上面两种方法还有一个问题，就是会吃服务器的资源，占用一定的 CPU 和内存，因为每次访问页面都要执行一下。但具体吃到什么程度，我就不清楚了，据说在服务器资源紧张的情况下压缩的效率会比较低，不过我想一般大型的主机提供商的主机还是不会有什么问题的。</p>
<p>第三种我们来看 <a href="http://www.thirdinfo.com/how-to-better-wp.htm">辐射鱼提供的方法</a></p>
<blockquote><p>1. 下载 <a href="http://wopus.googlecode.com/files/gzip.php">Gzip.php</a> 文件并上传到你的Wordpress安装目录</p>
<p>2. 在你的 Wordpress 根目录建立 wp-cache 文件夹并确保其可写入</p>
<p>3. 在.htaccess里面加上</p>
<p>RewriteRule (.*.css$|.*.js$) gzip.php?$1 [L]</p>
<p>即可</p></blockquote>
<p>也非常的简单，而且此种方法的优点是：自动读取并 gzip 压缩 css 和 js，访问时直接调用生成的 .gz 文件，节约带宽也不占用服务器资源，<strong>但不适用空间下安装了多个 Wordpress 的博友</strong>，可能导致二级目录下的某些 <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/wordpress" title="显示WordPress的所有日志" target="_blank">WordPress</a></span> 无法加载 CSS 样式。这些都是辐射鱼的原话，呵呵！另外就是当 CSS 和 JS 有更新时要手动清除缓存才行。符合条件的同志推荐用这种方法！！</p>
<p>转载自：<a title="http://www.xiaorsz.com/wordpress-gzip-compression-improve-the-speed/" href="http://www.xiaorsz.com/wordpress-gzip-compression-improve-the-speed/">http://www.xiaorsz.com/wordpress-gzip-compression-improve-the-speed/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xixis.net/archives/wordpress-speed-of-gzip-compression.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Best Practices for Speeding Up Your Web Site</title>
		<link>http://www.xixis.net/archives/best-practices-for-speeding-up-your-web-site.html</link>
		<comments>http://www.xixis.net/archives/best-practices-for-speeding-up-your-web-site.html#comments</comments>
		<pubDate>Mon, 01 Feb 2010 17:41:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[CDN]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[网站加速]]></category>

		<guid isPermaLink="false">http://www.xixis.net/?p=256</guid>
		<description><![CDATA[The Exceptional Performance team has identified a number of best practices for making web pages fast. The list includes 34 best practices divided into 7 categories.
fw from:http://developer.yahoo.com/performance/rules.html
 
Filter by category:

Content 
Server 
Cookie 
CSS 
Javascript 
Images 
Mobile 
All 


 
Minimize HTTP Requests
tag: content
80% of the end-user response time is spent on the front-end. Most of this time is tied up in downloading all the components in the page: images, stylesheets, scripts, Flash, etc. Reducing the number of components in turn reduces the number of HTTP requests required to render the page. ...]]></description>
			<content:encoded><![CDATA[<p>The Exceptional Performance team has identified a number of best practices for making web pages fast. The list includes 34 best practices divided into 7 categories.</p>
<p>fw from:<a title="http://developer.yahoo.com/performance/rules.html" href="http://developer.yahoo.com/performance/rules.html">http://developer.yahoo.com/performance/rules.html</a></p>
<p> <span id="more-256"></span>
<p>Filter by category:</p>
<ul>
<li>Content </li>
<li>Server </li>
<li>Cookie </li>
<li>CSS </li>
<li>Javascript </li>
<li>Images </li>
<li>Mobile </li>
<li>All </li>
</ul>
<ol></ol>
<p> <!–-nextpage-–><br />
<h5>Minimize HTTP Requests</h5>
<p>tag: content</p>
<p>80% of the end-user response time is spent on the front-end. Most of this time is tied up in downloading all the components in the page: images, stylesheets, scripts, Flash, etc. Reducing the number of components in turn reduces the number of HTTP requests required to render the page. This is the key to faster pages. </p>
<p>One way to reduce the number of components in the page is to simplify the page&#8217;s design. But is there a way to build pages with richer content while also achieving fast response times? Here are some techniques for reducing the number of HTTP requests, while still supporting rich page designs.</p>
<p><strong>Combined files</strong> are a way to reduce the number of HTTP requests by combining all scripts into a single script, and similarly combining all CSS into a single stylesheet. Combining files is more challenging when the scripts and stylesheets vary from page to page, but making this part of your release process improves response times.</p>
</p>
<p> </a><a href="http://alistapart.com/articles/sprites"><strong>CSS Sprites</strong></a> are the preferred method for reducing the number of image requests. Combine your background images into a single image and use the CSS <code>background-image</code> and <code>background-position</code> properties to display the desired image segment.</a>
<p><a href="http://www.w3.org/TR/html401/struct/objects.html#h-13.6"><strong>Image maps</strong></a> combine multiple images into a single image. The overall size is about the same, but reducing the number of HTTP requests speeds up the page. Image maps only work if the images are contiguous in the page, such as a navigation bar. Defining the coordinates of image maps can be tedious and error prone. Using image maps for navigation is not accessible too, so it&#8217;s not recommended.</p>
<p><strong>Inline images</strong> use the <a href="http://tools.ietf.org/html/rfc2397"><code>data:</code> URL scheme</a> to embed the image data in the actual page. This can increase the size of your HTML document. Combining inline images into your (cached) stylesheets is a way to reduce HTTP requests and avoid increasing the size of your pages. Inline images are not yet supported across all major browsers.</p>
<p>Reducing the number of HTTP requests in your page is the place to start. This is the most important guideline for improving performance for first time visitors. As described in Tenni Theurer&#8217;s blog post <a href="http://yuiblog.com/blog/2007/01/04/performance-research-part-2/">Browser Cache Usage &#8211; Exposed!</a>, 40-60% of daily visitors to your site come in with an empty cache. Making your page fast for these first time visitors is key to a better user experience.</p>
<p>&#160;</p>
<h5>Use a Content Delivery Network</h5>
<p>tag: <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/server" title="显示server的所有日志" target="_blank">server</a></span></p>
<p>The user&#8217;s proximity to your web <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/server" title="显示server的所有日志" target="_blank">server</a></span> has an impact on response times. Deploying your content across multiple, geographically dispersed servers will make your pages load faster from the user&#8217;s perspective. But where should you start?</p>
<p>As a first step to implementing geographically dispersed content, don&#8217;t attempt to redesign your web application to work in a distributed architecture. Depending on the application, changing the architecture could include daunting tasks such as synchronizing session state and replicating database transactions across <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/server" title="显示server的所有日志" target="_blank">server</a></span> locations. Attempts to reduce the distance between users and your content could be delayed by, or never pass, this application architecture step. </p>
<p>Remember that 80-90% of the end-user response time is spent downloading all the components in the page: images, stylesheets, scripts, Flash, etc. This is the <em>Performance Golden Rule</em>. Rather than starting with the difficult task of redesigning your application architecture, it&#8217;s better to first disperse your static content. This not only achieves a bigger reduction in response times, but it&#8217;s easier thanks to content delivery networks.</p>
<p>A content delivery network (<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/cdn" title="显示CDN的所有日志" target="_blank">CDN</a></span>) is a collection of web servers distributed across multiple locations to deliver content more efficiently to users. The server selected for delivering content to a specific user is typically based on a measure of network proximity. For example, the server with the fewest network hops or the server with the quickest response time is chosen.</p>
<p>Some large Internet companies own their own <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/cdn" title="显示CDN的所有日志" target="_blank">CDN</a></span>, but it&#8217;s cost-effective to use a CDN service provider, such as <a href="http://www.akamai.com/">Akamai Technologies</a>, <a href="http://www.mirror-image.com/">Mirror Image Internet</a>, or <a href="http://www.limelightnetworks.com/">Limelight Networks</a>. For start-up companies and private web sites, the cost of a CDN service can be prohibitive, but as your target audience grows larger and becomes more global, a CDN is necessary to achieve fast response times. At Yahoo!, properties that moved static content off their application web servers to a CDN improved end-user response times by 20% or more. Switching to a CDN is a relatively easy code change that will dramatically improve the speed of your web site.</p>
<p>&#160;</p>
<p> <!–-nextpage-–><br />
<h5>Add an Expires or a Cache-Control Header</h5>
<p>tag: server</p>
<p>There are two things in this rule:</p>
<ul>
<li>For static components: implement &quot;Never expire&quot; policy by setting far future <code>Expires</code> header </li>
<li>For dynamic components: use an appropriate <code>Cache-Control</code> header to help the browser with conditional requests </li>
</ul>
<p>Web page designs are getting richer and richer, which means more scripts, stylesheets, images, and Flash in the page. A first-time visitor to your page may have to make several HTTP requests, but by using the Expires header you make those components cacheable. This avoids unnecessary HTTP requests on subsequent page views. Expires headers are most often used with images, but they should be used on <em>all</em> components including scripts, stylesheets, and Flash components.</p>
<p>Browsers (and proxies) use a cache to reduce the number and size of HTTP requests, making web pages load faster. A web server uses the Expires header in the HTTP response to tell the client how long a component can be cached. This is a far future Expires header, telling the browser that this response won&#8217;t be stale until April 15, 2010. </p>
<pre>      Expires: Thu, 15 Apr 2010 20:00:00 GMT</pre>
<p>If your server is Apache, use the ExpiresDefault directive to set an expiration date relative to the current date. This example of the ExpiresDefault directive sets the Expires date 10 years out from the time of the request.</p>
<pre>      ExpiresDefault &quot;access plus 10 years&quot;</pre>
<p>Keep in mind, if you use a far future Expires header you have to change the component&#8217;s filename whenever the component changes. At Yahoo! we often make this step part of the build process: a version number is embedded in the component&#8217;s filename, for example, yahoo_2.0.6.js.</p>
<p>Using a far future Expires header affects page views only after a user has already visited your site. It has no effect on the number of HTTP requests when a user visits your site for the first time and the browser&#8217;s cache is empty. Therefore the impact of this performance improvement depends on how often users hit your pages with a primed cache. (A &quot;primed cache&quot; already contains all of the components in the page.) We <a href="http://yuiblog.com/blog/2007/01/04/performance-research-part-2/">measured this at Yahoo!</a> and found the number of page views with a primed cache is 75-85%. By using a far future Expires header, you increase the number of components that are cached by the browser and re-used on subsequent page views without sending a single byte over the user&#8217;s Internet connection.</p>
<p>&#160;</p>
<h5>Gzip Components</h5>
<p>tag: server</p>
<p>The time it takes to transfer an HTTP request and response across the network can be significantly reduced by decisions made by front-end engineers. It&#8217;s true that the end-user&#8217;s bandwidth speed, Internet service provider, proximity to peering exchange points, etc. are beyond the control of the development team. But there are other variables that affect response times. Compression reduces response times by reducing the size of the HTTP response.</p>
<p>Starting with HTTP/1.1, web clients indicate support for compression with the Accept-Encoding header in the HTTP request.</p>
<pre>      Accept-Encoding: <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/gzip" title="显示gzip的所有日志" target="_blank">gzip</a></span>, deflate</pre>
<p>If the web server sees this header in the request, it may compress the response using one of the methods listed by the client. The web server notifies the web client of this via the Content-Encoding header in the response.</p>
<pre>      Content-Encoding: <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/gzip" title="显示gzip的所有日志" target="_blank">gzip</a></span></pre>
<p>Gzip is the most popular and effective compression method at this time. It was developed by the GNU project and standardized by <a href="http://www.ietf.org/rfc/rfc1952.txt">RFC 1952</a>. The only other compression format you&#8217;re likely to see is deflate, but it&#8217;s less effective and less popular. </p>
<p>Gzipping generally reduces the response size by about 70%. Approximately 90% of today&#8217;s Internet traffic travels through browsers that claim to support <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/gzip" title="显示gzip的所有日志" target="_blank">gzip</a></span>. If you use Apache, the module configuring gzip depends on your version: Apache 1.3 uses <a href="http://sourceforge.net/projects/mod-gzip/">mod_gzip</a> while Apache 2.x uses <a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html">mod_deflate</a>. </p>
<p>There are known issues with browsers and proxies that may cause a mismatch in what the browser expects and what it receives with regard to compressed content. Fortunately, these edge cases are dwindling as the use of older browsers drops off. The Apache modules help out by adding appropriate Vary response headers automatically. </p>
<p>Servers choose what to gzip based on file type, but are typically too limited in what they decide to compress. Most web sites gzip their HTML documents. It&#8217;s also worthwhile to gzip your scripts and stylesheets, but many web sites miss this opportunity. In fact, it&#8217;s worthwhile to compress any text response including XML and JSON. Image and PDF files should not be gzipped because they are already compressed. Trying to gzip them not only wastes CPU but can potentially increase file sizes. </p>
<p>Gzipping as many file types as possible is an easy way to reduce page weight and accelerate the user experience.</p>
<p>&#160;</p>
<p><!–-nextpage-–></p>
<h5>Put Stylesheets at the Top</h5>
<p>tag: <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/css" title="显示css的所有日志" target="_blank">css</a></span></p>
<p>While researching performance at Yahoo!, we discovered that moving stylesheets to the document HEAD makes pages <em>appear</em> to be loading faster. This is because putting stylesheets in the HEAD allows the page to render progressively. </p>
<p>Front-end engineers that care about performance want a page to load progressively; that is, we want the browser to display whatever content it has as soon as possible. This is especially important for pages with a lot of content and for users on slower Internet connections. The importance of giving users visual feedback, such as progress indicators, has been well researched and <a href="http://www.useit.com/papers/responsetime.html">documented</a>. In our case the HTML page is the progress indicator! When the browser loads the page progressively the header, the navigation bar, the logo at the top, etc. all serve as visual feedback for the user who is waiting for the page. This improves the overall user experience.</p>
<p>The problem with putting stylesheets near the bottom of the document is that it prohibits progressive rendering in many browsers, including Internet Explorer. These browsers block rendering to avoid having to redraw elements of the page if their styles change. The user is stuck viewing a blank white page. </p>
<p>The <a href="http://www.w3.org/TR/html4/struct/links.html#h-12.3">HTML specification</a> clearly states that stylesheets are to be included in the HEAD of the page: &quot;Unlike A, [LINK] may only appear in the HEAD section of a document, although it may appear any number of times.&quot; Neither of the alternatives, the blank white screen or flash of unstyled content, are worth the risk. The optimal solution is to follow the HTML specification and load your stylesheets in the document HEAD.</p>
<p>&#160;</p>
<h5>Put Scripts at the Bottom</h5>
<p>tag: javascript</p>
<p>The problem caused by scripts is that they block parallel downloads. The <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1.4">HTTP/1.1 specification</a> suggests that browsers download no more than two components in parallel per hostname. If you serve your images from multiple hostnames, you can get more than two downloads to occur in parallel. While a script is downloading, however, the browser won&#8217;t start any other downloads, even on different hostnames. </p>
<p>In some situations it&#8217;s not easy to move scripts to the bottom. If, for example, the script uses <code>document.write</code> to insert part of the page&#8217;s content, it can&#8217;t be moved lower in the page. There might also be scoping issues. In many cases, there are ways to workaround these situations.</p>
<p>An alternative suggestion that often comes up is to use deferred scripts. The <code>DEFER</code> attribute indicates that the script does not contain document.write, and is a clue to browsers that they can continue rendering. Unfortunately, Firefox doesn&#8217;t support the <code>DEFER</code> attribute. In Internet Explorer, the script may be deferred, but not as much as desired. If a script can be deferred, it can also be moved to the bottom of the page. That will make your web pages load faster.</p>
<p>&#160;</p>
<p><!–-nextpage-–></p>
<h5>Avoid CSS Expressions</h5>
<p>tag: <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/css" title="显示css的所有日志" target="_blank">css</a></span></p>
<p>CSS expressions are a powerful (and dangerous) way to set CSS properties dynamically. They&#8217;re supported in Internet Explorer, starting with <a href="http://msdn.microsoft.com/workshop/author/dhtml/overview/recalc.asp">version 5</a>. As an example, the background color could be set to alternate every hour using CSS expressions.</p>
<pre>      background-color: expression( (new Date()).getHours()%2 ? &quot;#B8D4FF&quot; : &quot;#F08A00&quot; );</pre>
<p>As shown here, the <code>expression</code> method accepts a JavaScript expression. The CSS property is set to the result of evaluating the JavaScript expression. The <code>expression</code> method is ignored by other browsers, so it is useful for setting properties in Internet Explorer needed to create a consistent experience across browsers.</p>
<p>The problem with expressions is that they are evaluated more frequently than most people expect. Not only are they evaluated when the page is rendered and resized, but also when the page is scrolled and even when the user moves the mouse over the page. Adding a counter to the CSS expression allows us to keep track of when and how often a CSS expression is evaluated. Moving the mouse around the page can easily generate more than 10,000 evaluations.</p>
<p>One way to reduce the number of times your CSS expression is evaluated is to use one-time expressions, where the first time the expression is evaluated it sets the style property to an explicit value, which replaces the CSS expression. If the style property must be set dynamically throughout the life of the page, using event handlers instead of CSS expressions is an alternative approach. If you must use CSS expressions, remember that they may be evaluated thousands of times and could affect the performance of your page.</p>
<p>&#160;</p>
<p><!–-nextpage-–></p>
<h5>Make JavaScript and CSS External</h5>
<p>tag: javascript, <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/css" title="显示css的所有日志" target="_blank">css</a></span></p>
<p>Many of these performance rules deal with how external components are managed. However, before these considerations arise you should ask a more basic question: Should JavaScript and CSS be contained in external files, or inlined in the page itself?</p>
<p>Using external files in the real world generally produces faster pages because the JavaScript and CSS files are cached by the browser. JavaScript and CSS that are inlined in HTML documents get downloaded every time the HTML document is requested. This reduces the number of HTTP requests that are needed, but increases the size of the HTML document. On the other hand, if the JavaScript and CSS are in external files cached by the browser, the size of the HTML document is reduced without increasing the number of HTTP requests. </p>
<p>The key factor, then, is the frequency with which external JavaScript and CSS components are cached relative to the number of HTML documents requested. This factor, although difficult to quantify, can be gauged using various metrics. If users on your site have multiple page views per session and many of your pages re-use the same scripts and stylesheets, there is a greater potential benefit from cached external files. </p>
<p>Many web sites fall in the middle of these metrics. For these sites, the best solution generally is to deploy the JavaScript and CSS as external files. The only exception where inlining is preferable is with home pages, such as <a href="http://www.yahoo.com">Yahoo!&#8217;s front page</a> and <a href="http://my.yahoo.com">My Yahoo!</a>. Home pages that have few (perhaps only one) page view per session may find that inlining JavaScript and CSS results in faster end-user response times.</p>
<p>For front pages that are typically the first of many page views, there are techniques that leverage the reduction of HTTP requests that inlining provides, as well as the caching benefits achieved through using external files. One such technique is to inline JavaScript and CSS in the front page, but dynamically download the external files after the page has finished loading. Subsequent pages would reference the external files that should already be in the browser&#8217;s cache.</p>
<p>&#160;</p>
<p><!–-nextpage-–></p>
<h5>Reduce DNS Lookups</h5>
<p>tag: content</p>
<p>The Domain Name System (DNS) maps hostnames to IP addresses, just as phonebooks map people&#8217;s names to their phone numbers. When you type www.yahoo.com into your browser, a DNS resolver contacted by the browser returns that server&#8217;s IP address. DNS has a cost. It typically takes 20-120 milliseconds for DNS to lookup the IP address for a given hostname. The browser can&#8217;t download anything from this hostname until the DNS lookup is completed. </p>
<p>DNS lookups are cached for better performance. This caching can occur on a special caching server, maintained by the user&#8217;s ISP or local area network, but there is also caching that occurs on the individual user&#8217;s computer. The DNS information remains in the operating system&#8217;s DNS cache (the &quot;DNS Client service&quot; on Microsoft Windows). Most browsers have their own caches, separate from the operating system&#8217;s cache. As long as the browser keeps a DNS record in its own cache, it doesn&#8217;t bother the operating system with a request for the record.</p>
<p>Internet Explorer caches DNS lookups for 30 minutes by default, as specified by the <code>DnsCacheTimeout</code> registry setting. Firefox caches DNS lookups for 1 minute, controlled by the <code>network.dnsCacheExpiration</code> configuration setting. (Fasterfox changes this to 1 hour.)</p>
<p>When the client&#8217;s DNS cache is empty (for both the browser and the operating system), the number of DNS lookups is equal to the number of unique hostnames in the web page. This includes the hostnames used in the page&#8217;s URL, images, script files, stylesheets, Flash objects, etc. Reducing the number of unique hostnames reduces the number of DNS lookups. </p>
<p>Reducing the number of unique hostnames has the potential to reduce the amount of parallel downloading that takes place in the page. Avoiding DNS lookups cuts response times, but reducing parallel downloads may increase response times. My guideline is to split these components across at least two but no more than four hostnames. This results in a good compromise between reducing DNS lookups and allowing a high degree of parallel downloads.</p>
<p>&#160;</p>
<p><!–-nextpage-–></p>
<h5>Minify JavaScript and CSS</h5>
<p>tag: javascript, css</p>
<p>Minification is the practice of removing unnecessary characters from code to reduce its size thereby improving load times. When code is minified all comments are removed, as well as unneeded white space characters (space, newline, and tab). In the case of JavaScript, this improves response time performance because the size of the downloaded file is reduced. Two popular tools for minifying JavaScript code are <a href="http://crockford.com/javascript/jsmin">JSMin</a> and <a href="http://developer.yahoo.com/yui/compressor/">YUI Compressor</a>. The YUI compressor can also minify CSS.</p>
<p>Obfuscation is an alternative optimization that can be applied to source code. It&#8217;s more complex than minification and thus more likely to generate bugs as a result of the obfuscation step itself. In a survey of ten top U.S. web sites, minification achieved a 21% size reduction versus 25% for obfuscation. Although obfuscation has a higher size reduction, minifying JavaScript is less risky.</p>
<p>In addition to minifying external scripts and styles, inlined <code>&lt;script&gt;</code> and <code>&lt;style&gt;</code> blocks can and should also be minified. Even if you gzip your scripts and styles, minifying them will still reduce the size by 5% or more. As the use and size of JavaScript and CSS increases, so will the savings gained by minifying your code.</p>
<p>&#160;</p>
<p><!–-nextpage-–></p>
<h5>Avoid Redirects</h5>
<p>tag: content</p>
<p>Redirects are accomplished using the 301 and 302 status codes. Here&#8217;s an example of the HTTP headers in a 301 response:</p>
<pre>      HTTP/1.1 301 Moved Permanently
      Location: http://example.com/newuri
      Content-Type: text/html</pre>
<p>The browser automatically takes the user to the URL specified in the <code>Location</code> field. All the information necessary for a redirect is in the headers. The body of the response is typically empty. Despite their names, neither a 301 nor a 302 response is cached in practice unless additional headers, such as <code>Expires</code> or <code>Cache-Control</code>, indicate it should be. The meta refresh tag and JavaScript are other ways to direct users to a different URL, but if you must do a redirect, the preferred technique is to use the standard 3xx HTTP status codes, primarily to ensure the back button works correctly.</p>
<p>The main thing to remember is that redirects slow down the user experience. Inserting a redirect between the user and the HTML document delays everything in the page since nothing in the page can be rendered and no components can start being downloaded until the HTML document has arrived.</p>
<p>One of the most wasteful redirects happens frequently and web developers are generally not aware of it. It occurs when a trailing slash (/) is missing from a URL that should otherwise have one. For example, going to <a href="http://astrology.yahoo.com/astrology">http://astrology.yahoo.com/astrology</a> results in a 301 response containing a redirect to <a href="http://astrology.yahoo.com/astrology/">http://astrology.yahoo.com/astrology/</a> (notice the added trailing slash). This is fixed in Apache by using <code>Alias</code> or <code>mod_rewrite</code>, or the <code>DirectorySlash</code> directive if you&#8217;re using Apache handlers.</p>
<p>Connecting an old web site to a new one is another common use for redirects. Others include connecting different parts of a website and directing the user based on certain conditions (type of browser, type of user account, etc.). Using a redirect to connect two web sites is simple and requires little additional coding. Although using redirects in these situations reduces the complexity for developers, it degrades the user experience. Alternatives for this use of redirects include using <code>Alias</code> and <code>mod_rewrite</code> if the two code paths are hosted on the same server. If a domain name change is the cause of using redirects, an alternative is to create a CNAME (a DNS record that creates an alias pointing from one domain name to another) in combination with <code>Alias</code> or <code>mod_rewrite</code>.</p>
<p>&#160;</p>
<p><!–-nextpage-–></p>
<h5>Remove Duplicate Scripts</h5>
<p>tag: javascript</p>
<p>It hurts performance to include the same JavaScript file twice in one page. This isn&#8217;t as unusual as you might think. A review of the ten top U.S. web sites shows that two of them contain a duplicated script. Two main factors increase the odds of a script being duplicated in a single web page: team size and number of scripts. When it does happen, duplicate scripts hurt performance by creating unnecessary HTTP requests and wasted JavaScript execution.</p>
<p>Unnecessary HTTP requests happen in Internet Explorer, but not in Firefox. In Internet Explorer, if an external script is included twice and is not cacheable, it generates two HTTP requests during page loading. Even if the script is cacheable, extra HTTP requests occur when the user reloads the page.</p>
<p>In addition to generating wasteful HTTP requests, time is wasted evaluating the script multiple times. This redundant JavaScript execution happens in both Firefox and Internet Explorer, regardless of whether the script is cacheable.</p>
<p>One way to avoid accidentally including the same script twice is to implement a script management module in your templating system. The typical way to include a script is to use the SCRIPT tag in your HTML page.</p>
<pre>      &lt;script type=&quot;text/javascript&quot; src=&quot;menu_1.0.17.js&quot;&gt;&lt;/script&gt;</pre>
<p>An alternative in PHP would be to create a function called <code>insertScript</code>.</p>
<pre>      &lt;?php insertScript(&quot;menu.js&quot;) ?&gt;</pre>
<p>In addition to preventing the same script from being inserted multiple times, this function could handle other issues with scripts, such as dependency checking and adding version numbers to script filenames to support far future Expires headers.</p>
<p>&#160;</p>
<p><!–-nextpage-–></p>
<h5>Configure ETags</h5>
<p>tag: server</p>
<p>Entity tags (ETags) are a mechanism that web servers and browsers use to determine whether the component in the browser&#8217;s cache matches the one on the origin server. (An &quot;entity&quot; is another word a &quot;component&quot;: images, scripts, stylesheets, etc.) ETags were added to provide a mechanism for validating entities that is more flexible than the last-modified date. An ETag is a string that uniquely identifies a specific version of a component. The only format constraints are that the string be quoted. The origin server specifies the component&#8217;s ETag using the <code>ETag</code> response header.</p>
<pre>      HTTP/1.1 200 OK
      Last-Modified: Tue, 12 Dec 2006 03:03:59 GMT
      ETag: &quot;10c24bc-4ab-457e1c1f&quot;
      Content-Length: 12195</pre>
<p>Later, if the browser has to validate a component, it uses the <code>If-None-Match</code> header to pass the ETag back to the origin server. If the ETags match, a 304 status code is returned reducing the response by 12195 bytes for this example. </p>
<pre>      GET /i/yahoo.gif HTTP/1.1
      Host: us.yimg.com
      If-Modified-Since: Tue, 12 Dec 2006 03:03:59 GMT
      If-None-Match: &quot;10c24bc-4ab-457e1c1f&quot;
      HTTP/1.1 304 Not Modified</pre>
<p>The problem with ETags is that they typically are constructed using attributes that make them unique to a specific server hosting a site. ETags won&#8217;t match when a browser gets the original component from one server and later tries to validate that component on a different server, a situation that is all too common on Web sites that use a cluster of servers to handle requests. By default, both Apache and IIS embed data in the ETag that dramatically reduces the odds of the validity test succeeding on web sites with multiple servers. </p>
<p>The ETag format for Apache 1.3 and 2.x is <code>inode-size-timestamp</code>. Although a given file may reside in the same directory across multiple servers, and have the same file size, permissions, timestamp, etc., its inode is different from one server to the next. </p>
<p>IIS 5.0 and 6.0 have a similar issue with ETags. The format for ETags on IIS is <code>Filetimestamp:ChangeNumber</code>. A <code>ChangeNumber</code> is a counter used to track configuration changes to IIS. It&#8217;s unlikely that the <code>ChangeNumber</code> is the same across all IIS servers behind a web site. </p>
<p>The end result is ETags generated by Apache and IIS for the exact same component won&#8217;t match from one server to another. If the ETags don&#8217;t match, the user doesn&#8217;t receive the small, fast 304 response that ETags were designed for; instead, they&#8217;ll get a normal 200 response along with all the data for the component. If you host your web site on just one server, this isn&#8217;t a problem. But if you have multiple servers hosting your web site, and you&#8217;re using Apache or IIS with the default ETag configuration, your users are getting slower pages, your servers have a higher load, you&#8217;re consuming greater bandwidth, and proxies aren&#8217;t caching your content efficiently. Even if your components have a far future <code>Expires</code> header, a conditional GET request is still made whenever the user hits Reload or Refresh. </p>
<p>If you&#8217;re not taking advantage of the flexible validation model that ETags provide, it&#8217;s better to just remove the ETag altogether. The <code>Last-Modified</code> header validates based on the component&#8217;s timestamp. And removing the ETag reduces the size of the HTTP headers in both the response and subsequent requests. This <a href="http://support.microsoft.com/?id=922733">Microsoft Support article</a> describes how to remove ETags. In Apache, this is done by simply adding the following line to your Apache configuration file: </p>
<pre>      FileETag none</pre>
<p>&#160;</p>
<p><!–-nextpage-–></p>
<h5>Make Ajax Cacheable</h5>
<p>tag: content</p>
<p>One of the cited benefits of Ajax is that it provides instantaneous feedback to the user because it requests information asynchronously from the backend web server. However, using Ajax is no guarantee that the user won&#8217;t be twiddling his thumbs waiting for those asynchronous JavaScript and XML responses to return. In many applications, whether or not the user is kept waiting depends on how Ajax is used. For example, in a web-based email client the user will be kept waiting for the results of an Ajax request to find all the email messages that match their search criteria. It&#8217;s important to remember that &quot;asynchronous&quot; does not imply &quot;instantaneous&quot;.</p>
<p>To improve performance, it&#8217;s important to optimize these Ajax responses. The most important way to improve the performance of Ajax is to make the responses cacheable, as discussed in <a href="http://developer.yahoo.com/performance/rules.html#expires">Add an Expires or a Cache-Control Header</a>. Some of the other rules also apply to Ajax:</p>
<ul>
<li><a href="http://developer.yahoo.com/performance/rules.html#gzip">Gzip Components</a> </li>
<li><a href="http://developer.yahoo.com/performance/rules.html#dns_lookups">Reduce DNS Lookups</a> </li>
<li><a href="http://developer.yahoo.com/performance/rules.html#minify">Minify JavaScript</a> </li>
<li><a href="http://developer.yahoo.com/performance/rules.html#redirects">Avoid Redirects</a> </li>
<li><a href="http://developer.yahoo.com/performance/rules.html#etags">Configure ETags</a> </li>
</ul>
<p>Let&#8217;s look at an example. A Web 2.0 email client might use Ajax to download the user&#8217;s address book for autocompletion. If the user hasn&#8217;t modified her address book since the last time she used the email web app, the previous address book response could be read from cache if that Ajax response was made cacheable with a future Expires or Cache-Control header. The browser must be informed when to use a previously cached address book response versus requesting a new one. This could be done by adding a timestamp to the address book Ajax URL indicating the last time the user modified her address book, for example, <code>&amp;t=1190241612</code>. If the address book hasn&#8217;t been modified since the last download, the timestamp will be the same and the address book will be read from the browser&#8217;s cache eliminating an extra HTTP roundtrip. If the user has modified her address book, the timestamp ensures the new URL doesn&#8217;t match the cached response, and the browser will request the updated address book entries.</p>
<p>Even though your Ajax responses are created dynamically, and might only be applicable to a single user, they can still be cached. Doing so will make your Web 2.0 apps faster.</p>
<p>&#160;</p>
<h5>Flush the Buffer Early</h5>
<p>tag: server</p>
<p>When users request a page, it can take anywhere from 200 to 500ms for the backend server to stitch together the HTML page. During this time, the browser is idle as it waits for the data to arrive. In PHP you have the function <a href="http://php.net/flush">flush()</a>. It allows you to send your partially ready HTML response to the browser so that the browser can start fetching components while your backend is busy with the rest of the HTML page. The benefit is mainly seen on busy backends or light frontends. </p>
<p>A good place to consider flushing is right after the HEAD because the HTML for the head is usually easier to produce and it allows you to include any CSS and JavaScript files for the browser to start fetching in parallel while the backend is still processing. </p>
<p>Example:</p>
<pre>      ... &lt;!-- css, js --&gt;
    &lt;/head&gt;
    &lt;?php flush(); ?&gt;
    &lt;body&gt;
      ... &lt;!-- content --&gt;</pre>
<p><a href="http://search.yahoo.com">Yahoo! search</a> pioneered research and real user testing to prove the benefits of using this technique.</p>
<p>&#160;</p>
<h5>Use GET for AJAX Requests</h5>
<p>tag: server</p>
<p>The <a href="http://mail.yahoo.com">Yahoo! Mail</a> team found that when using <code>XMLHttpRequest</code>, POST is implemented in the browsers as a two-step process: sending the headers first, then sending data. So it&#8217;s best to use GET, which only takes one TCP packet to send (unless you have a lot of cookies). The maximum URL length in IE is 2K, so if you send more than 2K data you might not be able to use GET. </p>
<p>An interesting side affect is that POST without actually posting any data behaves like GET. Based on the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html">HTTP specs</a>, GET is meant for retrieving information, so it makes sense (semantically) to use GET when you&#8217;re only requesting data, as opposed to sending data to be stored server-side. </p>
<p>&#160;</p>
<p><!–-nextpage-–></p>
<h5>Post-load Components</h5>
<p>tag: content</p>
<p>You can take a closer look at your page and ask yourself: &quot;What&#8217;s absolutely required in order to render the page initially?&quot;. The rest of the content and components can wait. </p>
<p>JavaScript is an ideal candidate for splitting before and after the onload event. For example if you have JavaScript code and libraries that do drag and drop and animations, those can wait, because dragging elements on the page comes after the initial rendering. Other places to look for candidates for post-loading include hidden content (content that appears after a user action) and images below the fold. </p>
<p>Tools to help you out in your effort: <a href="http://developer.yahoo.com/yui/imageloader/">YUI Image Loader</a> allows you to delay images below the fold and the <a href="http://developer.yahoo.com/yui/get/">YUI Get utility</a> is an easy way to include JS and CSS on the fly. For an example in the wild take a look at <a href="http://www.yahoo.com">Yahoo! Home Page</a> with Firebug&#8217;s Net Panel turned on. </p>
<p>It&#8217;s good when the performance goals are inline with other web development best practices. In this case, the idea of progressive enhancement tells us that JavaScript, when supported, can improve the user experience but you have to make sure the page works even without JavaScript. So after you&#8217;ve made sure the page works fine, you can enhance it with some post-loaded scripts that give you more bells and whistles such as drag and drop and animations. </p>
<p>&#160;</p>
<h5>Preload Components</h5>
<p>tag: content</p>
<p>Preload may look like the opposite of post-load, but it actually has a different goal. By preloading components you can take advantage of the time the browser is idle and request components (like images, styles and scripts) you&#8217;ll need in the future. This way when the user visits the next page, you could have most of the components already in the cache and your page will load much faster for the user. </p>
<p>There are actually several types of preloading: </p>
<ul>
<li><em>Unconditional</em> preload &#8211; as soon as onload fires, you go ahead and fetch some extra components. Check google.com for an example of how a sprite image is requested onload. This sprite image is not needed on the google.com homepage, but it is needed on the consecutive search result page. </li>
<li><em>Conditional</em> preload &#8211; based on a user action you make an educated guess where the user is headed next and preload accordingly. On <a href="http://search.yahoo.com">search.yahoo.com</a> you can see how some extra components are requested after you start typing in the input box. </li>
<li><em>Anticipated</em> preload &#8211; preload in advance before launching a redesign. It often happens after a redesign that you hear: &quot;The new site is cool, but it&#8217;s slower than before&quot;. Part of the problem could be that the users were visiting your old site with a full cache, but the new one is always an empty cache experience. You can mitigate this side effect by preloading some components before you even launched the redesign. Your old site can use the time the browser is idle and request images and scripts that will be used by the new site </li>
</ul>
<p>&#160;</p>
<h5>Reduce the Number of DOM Elements</h5>
<p>tag: content</p>
<p>A complex page means more bytes to download and it also means slower DOM access in JavaScript. It makes a difference if you loop through 500 or 5000 DOM elements on the page when you want to add an event handler for example. </p>
<p>A high number of DOM elements can be a symptom that there&#8217;s something that should be improved with the markup of the page without necessarily removing content. Are you using nested tables for layout purposes? Are you throwing in more <code>&lt;div&gt;</code>s only to fix layout issues? Maybe there&#8217;s a better and more semantically correct way to do your markup. </p>
<p>A great help with layouts are the <a href="http://developer.yahoo.com/yui/">YUI CSS utilities</a>: grids.css can help you with the overall layout, fonts.css and reset.css can help you strip away the browser&#8217;s defaults formatting. This is a chance to start fresh and think about your markup, for example use <code>&lt;div&gt;</code>s only when it makes sense semantically, and not because it renders a new line. </p>
<p>The number of DOM elements is easy to test, just type in Firebug&#8217;s console:<br />
  <br /><code>document.getElementsByTagName('*').length</code></p>
<p>And how many DOM elements are too many? Check other similar pages that have good markup. For example the <a href="http://www.yahoo.com">Yahoo! Home Page</a> is a pretty busy page and still under 700 elements (HTML tags). </p>
<p>&#160;</p>
<p><!–-nextpage-–></p>
<h5>Split Components Across Domains</h5>
<p>tag: content</p>
<p>Splitting components allows you to maximize parallel downloads. Make sure you&#8217;re using not more than 2-4 domains because of the DNS lookup penalty. For example, you can host your HTML and dynamic content on <code>www.example.org</code> and split static components between <code>static1.example.org</code> and <code>static2.example.org</code></p>
<p>For more information check &quot;<a href="http://yuiblog.com/blog/2007/04/11/performance-research-part-4/">Maximizing Parallel Downloads in the Carpool Lane</a>&quot; by Tenni Theurer and Patty Chi. </p>
<p>&#160;</p>
<h5>Minimize the Number of iframes</h5>
<p>tag: content</p>
<p>Iframes allow an HTML document to be inserted in the parent document. It&#8217;s important to understand how iframes work so they can be used effectively. </p>
<p><code>&lt;iframe&gt;</code> pros: </p>
<ul>
<li>Helps with slow third-party content like badges and ads </li>
<li>Security sandbox </li>
<li>Download scripts in parallel </li>
</ul>
<p><code>&lt;iframe&gt;</code> cons: </p>
<ul>
<li>Costly even if blank </li>
<li>Blocks page onload </li>
<li>Non-semantic </li>
</ul>
<p>&#160;</p>
<h5>No 404s</h5>
<p>tag: content</p>
<p>HTTP requests are expensive so making an HTTP request and getting a useless response (i.e. 404 Not Found) is totally unnecessary and will slow down the user experience without any benefit. </p>
<p>Some sites have helpful 404s &quot;Did you mean X?&quot;, which is great for the user experience but also wastes server resources (like database, etc). Particularly bad is when the link to an external JavaScript is wrong and the result is a 404. First, this download will block parallel downloads. Next the browser may try to parse the 404 response body as if it were JavaScript code, trying to find something usable in it. </p>
<p>&#160;</p>
<p><!–-nextpage-–></p>
<h5>Reduce Cookie Size</h5>
<p>tag: cookie</p>
<p>HTTP cookies are used for a variety of reasons such as authentication and personalization. Information about cookies is exchanged in the HTTP headers between web servers and browsers. It&#8217;s important to keep the size of cookies as low as possible to minimize the impact on the user&#8217;s response time. </p>
<p>For more information check <a href="http://yuiblog.com/blog/2007/03/01/performance-research-part-3/">&quot;When the Cookie Crumbles&quot;</a> by Tenni Theurer and Patty Chi. The take-home of this research: </p>
<ul>
<li>Eliminate unnecessary cookies </li>
<li>Keep cookie sizes as low as possible to minimize the impact on the user response time </li>
<li>Be mindful of setting cookies at the appropriate domain level so other sub-domains are not affected </li>
<li>Set an Expires date appropriately. An earlier Expires date or none removes the cookie sooner, improving the user response time </li>
</ul>
<p>&#160;</p>
<h5>Use Cookie-free Domains for Components</h5>
<p>tag: cookie</p>
<p>When the browser makes a request for a static image and sends cookies together with the request, the server doesn&#8217;t have any use for those cookies. So they only create network traffic for no good reason. You should make sure static components are requested with cookie-free requests. Create a subdomain and host all your static components there. </p>
<p>If your domain is <code>www.example.org</code>, you can host your static components on <code>static.example.org</code>. However, if you&#8217;ve already set cookies on the top-level domain <code>example.org</code> as opposed to <code>www.example.org</code>, then all the requests to <code>static.example.org</code> will include those cookies. In this case, you can buy a whole new domain, host your static components there, and keep this domain cookie-free. Yahoo! uses <code>yimg.com</code>, YouTube uses <code>ytimg.com</code>, Amazon uses <code>images-amazon.com</code> and so on. </p>
<p>Another benefit of hosting static components on a cookie-free domain is that some proxies might refuse to cache the components that are requested with cookies. On a related note, if you wonder if you should use example.org or www.example.org for your home page, consider the cookie impact. Omitting www leaves you no choice but to write cookies to <code>*.example.org</code>, so for performance reasons it&#8217;s best to use the www subdomain and write the cookies to that subdomain. </p>
<p>&#160;</p>
<h5>Minimize DOM Access</h5>
<p>tag: javascript</p>
<p>Accessing DOM elements with JavaScript is slow so in order to have a more responsive page, you should: </p>
<ul>
<li>Cache references to accessed elements </li>
<li>Update nodes &quot;offline&quot; and then add them to the tree </li>
<li>Avoid fixing layout with JavaScript </li>
</ul>
<p>For more information check the YUI theatre&#8217;s <a href="http://yuiblog.com/blog/2007/12/20/video-lecomte/">&quot;High Performance Ajax Applications&quot;</a> by Julien Lecomte. </p>
<p>&#160;</p>
<p><!–-nextpage-–></p>
<h5>Develop Smart Event Handlers</h5>
<p>tag: javascript</p>
<p>Sometimes pages feel less responsive because of too many event handlers attached to different elements of the DOM tree which are then executed too often. That&#8217;s why using <em>event delegation</em> is a good approach. If you have 10 buttons inside a <code>div</code>, attach only one event handler to the div wrapper, instead of one handler for each button. Events bubble up so you&#8217;ll be able to catch the event and figure out which button it originated from. </p>
<p>You also don&#8217;t need to wait for the onload event in order to start doing something with the DOM tree. Often all you need is the element you want to access to be available in the tree. You don&#8217;t have to wait for all images to be downloaded. <code>DOMContentLoaded</code> is the event you might consider using instead of onload, but until it&#8217;s available in all browsers, you can use the <a href="http://developer.yahoo.com/yui/event/">YUI Event</a> utility, which has an <code><a href="http://developer.yahoo.com/yui/event/#onavailable">onAvailable</a></code> method. </p>
<p>For more information check the YUI theatre&#8217;s <a href="http://yuiblog.com/blog/2007/12/20/video-lecomte/">&quot;High Performance Ajax Applications&quot;</a> by Julien Lecomte. </p>
<p>&#160;</p>
<h5>Choose &lt;link&gt; over @import</h5>
<p>tag: css</p>
<p>One of the previous best practices states that CSS should be at the top in order to allow for progressive rendering. </p>
<p>In IE <code>@import</code> behaves the same as using <code>&lt;link&gt;</code> at the bottom of the page, so it&#8217;s best not to use it. </p>
<p>&#160;</p>
<h5>Avoid Filters</h5>
<p>tag: css</p>
<p>The IE-proprietary <code>AlphaImageLoader</code> filter aims to fix a problem with semi-transparent true color PNGs in IE versions &lt; 7. The problem with this filter is that it blocks rendering and freezes the browser while the image is being downloaded. It also increases memory consumption and is applied per element, not per image, so the problem is multiplied. </p>
<p>The best approach is to avoid <code>AlphaImageLoader</code> completely and use gracefully degrading PNG8 instead, which are fine in IE. If you absolutely need <code>AlphaImageLoader</code>, use the underscore hack <code>_filter</code> as to not penalize your IE7+ users. </p>
<p>&#160;</p>
<h5>Optimize Images</h5>
<p>tag: images</p>
<p>After a designer is done with creating the images for your web page, there are still some things you can try before you FTP those images to your web server. </p>
<ul>
<li>You can check the GIFs and see if they are using a palette size corresponding to the number of colors in the image. Using <a href="http://www.imagemagick.org">imagemagick</a> it&#8217;s easy to check using
<p><code>identify -verbose image.gif</code> </p>
<p>When you see an image useing 4 colors and a 256 color &quot;slots&quot; in the palette, there is room for improvement. </li>
<li>Try converting GIFs to PNGs and see if there is a saving. More often than not, there is. Developers often hesitate to use PNGs due to the limited support in browsers, but this is now a thing of the past. The only real problem is alpha-transparency in true color PNGs, but then again, GIFs are not true color and don&#8217;t support variable transparency either. So anything a GIF can do, a palette PNG (PNG8) can do too (except for animations). This simple imagemagick command results in totally safe-to-use PNGs:<br />
    <br /><code>convert image.gif image.png</code> </p>
<p>&quot;All we are saying is: Give PiNG a Chance!&quot; </li>
<li>Run <a href="http://pmt.sourceforge.net/pngcrush/">pngcrush</a> (or any other PNG optimizer tool) on all your PNGs. Example:
<p><code>pngcrush image.png -rem alla -reduce -brute result.png</code> </li>
<li>Run jpegtran on all your JPEGs. This tool does lossless JPEG operations such as rotation and can also be used to optimize and remove comments and other useless information (such as EXIF information) from your images.<br />
    <br /><code>jpegtran -copy none -optimize -perfect src.jpg dest.jpg</code> </li>
</ul>
<p>&#160;</p>
<p><!–-nextpage-–></p>
<h5>Optimize CSS Sprites</h5>
<p>tag: images</p>
<ul>
<li>Arranging the images in the sprite horizontally as opposed to vertically usually results in a smaller file size. </li>
<li>Combining similar colors in a sprite helps you keep the color count low, ideally under 256 colors so to fit in a PNG8. </li>
<li>&quot;Be mobile-friendly&quot; and don&#8217;t leave big gaps between the images in a sprite. This doesn&#8217;t affect the file size as much but requires less memory for the user agent to decompress the image into a pixel map. 100&#215;100 image is 10 thousand pixels, where 1000&#215;1000 is 1 million pixels </li>
</ul>
<p>&#160;</p>
<h5>Don&#8217;t Scale Images in HTML</h5>
<p>tag: images</p>
<p>Don&#8217;t use a bigger image than you need just because you can set the width and height in HTML. If you need<br />
  <br /><code>&lt;img width=&quot;100&quot; height=&quot;100&quot; src=&quot;mycat.jpg&quot; alt=&quot;My Cat&quot; /&gt;</code> </p>
<p>then your image (mycat.jpg) should be 100&#215;100px rather than a scaled down 500&#215;500px image. </p>
<p>&#160;</p>
<h5>Make favicon.ico Small and Cacheable</h5>
<p>tag: images</p>
<p>The favicon.ico is an image that stays in the root of your server. It&#8217;s a necessary evil because even if you don&#8217;t care about it the browser will still request it, so it&#8217;s better not to respond with a <code>404 Not Found</code>. Also since it&#8217;s on the same server, cookies are sent every time it&#8217;s requested. This image also interferes with the download sequence, for example in IE when you request extra components in the onload, the favicon will be downloaded before these extra components. </p>
<p>So to mitigate the drawbacks of having a favicon.ico make sure: </p>
<ul>
<li>It&#8217;s small, preferably under 1K. </li>
<li>Set Expires header with what you feel comfortable (since you cannot rename it if you decide to change it). You can probably safely set the Expires header a few months in the future. You can check the last modified date of your current favicon.ico to make an informed decision. </li>
</ul>
<p><a href="http://www.imagemagick.org">Imagemagick</a> can help you create small favicons </p>
<p>&#160;</p>
<h5>Keep Components under 25K</h5>
<p>tag: mobile</p>
<p>This restriction is related to the fact that iPhone won&#8217;t cache components bigger than 25K. Note that this is the <em>uncompressed</em> size. This is where minification is important because gzip alone may not be sufficient. </p>
<p>For more information check &quot;<a href="http://yuiblog.com/blog/2008/02/06/iphone-cacheability/">Performance Research, Part 5: iPhone Cacheability &#8211; Making it Stick</a>&quot; by Wayne Shea and Tenni Theurer. </p>
<p>&#160;</p>
<h5>Pack Components into a Multipart Document</h5>
<p>tag: mobile</p>
<p>Packing components into a multipart document is like an email with attachments, it helps you fetch several components with one HTTP request (remember: HTTP requests are expensive). When you use this technique, first check if the user agent supports it (iPhone does not). </p>
<p>top</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xixis.net/archives/best-practices-for-speeding-up-your-web-site.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>总结:CSS在IE与Firefox下的兼容性</title>
		<link>http://www.xixis.net/archives/summary-css-in-ie-and-firefox-compatibility-under-the.html</link>
		<comments>http://www.xixis.net/archives/summary-css-in-ie-and-firefox-compatibility-under-the.html#comments</comments>
		<pubDate>Thu, 06 Dec 2007 14:26:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[IE]]></category>

		<guid isPermaLink="false">http://127.0.0.1/wp7/?p=68</guid>
		<description><![CDATA[ &#160; &#160; 1.DOCTYPE 影响 CSS 处理 　　2.FF: div 设置 margin-left, margin-right 为 auto 时已经居中, IE 不行 　　3.FF: body 设置 text-align 时, div 需要设置 margin: auto(主要是 margin-left,margin-right) 方可居中 　　4.FF: 设置 padding 后, div 会增加 height 和 width, 但 IE 不会, 故需要用 !important 多设一个 height 和 width 　　5.FF: 支持 !important, IE 则忽略, 可用 !important 为 FF 特别设置样式，值得注意的是，一定要将xxxx !important 这句放置在另一句之上 　　6.div 的垂直居中问题: vertical-align:middle; 将行距增加到和整个DIV一样高 line-height:200px; 然后插入文字，就垂直居中了。缺点是要控制内容不要换行 　　7.cursor: pointer 可以同时在 IE FF 中显示游标手指状， hand 仅 IE 可以 　　8.FF: 链接加边框和背景色，需设置 display: block, 同时设置 float: left 保证不换行。参照 menubar, 给 a 和 menubar 设置高度是为了避免底边显示错位, 若不设 height, ...]]></description>
			<content:encoded><![CDATA[<p><span id="more-68"></span><br/> &nbsp; &nbsp; 1.DOCTYPE 影响 CSS 处理 <br/>　　2.FF: div 设置 margin-left, margin-right 为 auto 时已经居中, <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/ie" title="显示IE的所有日志" target="_blank">IE</a></span> 不行 <br/>　　3.FF: body 设置 text-align 时, div 需要设置 margin: auto(主要是 margin-left,margin-right) 方可居中 <br/>　　4.FF: 设置 padding 后, div 会增加 height 和 width, 但 <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/ie" title="显示IE的所有日志" target="_blank">IE</a></span> 不会, 故需要用 !important 多设一个 height 和 width <br/><br/>　　5.FF: 支持 !important, IE 则忽略, 可用 !important 为 FF 特别设置样式，值得注意的是，一定要将xxxx !important 这句放置在另一句之上 <br/><br/><br/>　　6.div 的垂直居中问题: vertical-align:middle; 将行距增加到和整个DIV一样高 line-height:200px; 然后插入文字，就垂直居中了。缺点是要控制内容不要换行 <br/><br/>　　7.cursor: pointer 可以同时在 IE FF 中显示游标手指状， hand 仅 IE 可以 <br/><br/><br/>　　8.FF: 链接加边框和背景色，需设置 display: block, 同时设置 float: left 保证不换行。参照 menubar, 给 a 和 menubar 设置高度是为了避免底边显示错位, 若不设 height, 可以在 menubar 中插入一个空格。 <br/><br/>　　9.在mozilla <span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/firefox" title="显示firefox的所有日志" target="_blank">firefox</a></span>和IE中的BOX模型解释不一致导致相差2px解决方法：div{margin:30px!important;margin:28px;} <br/><br/>　　注意这两个margin的顺序一定不能写反，据阿捷的说法!important这个属性IE不能识别，但别的浏览器可以识别。所以在IE下其实解释成这样：div{maring:30px;margin:28px} bitsCN.nET中国网管博客 <br/><br/>　　重复定义的话按照最后一个来执行，所以不可以只写margin:XXpx!important; bitsCN.nET中国网管博客 <br/><br/>　　10.IE5 和IE6的BOX解释不一致 <br/><br/>　　IE5下div{width:300px;margin:0 10px 0 10px;} <br/><br/>　　div的宽度会被解释为300px-10px(右填充)-10px(左填充)最终div的宽度为 280px，而在IE6和其他浏览器上宽度则是以300px+10px(右填充)+10px(左填充)=320px来计算的。这时我们可以做如下修改 div{width:300px!important;width /**/:340px;margin:0 10px 0 10px} bitsCN.Com <br/><br/>　　关于这个/**/是什么我也不太明白，只知道IE5和<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/firefox" title="显示firefox的所有日志" target="_blank">firefox</a></span>都支持但IE6不支持，如果有人理解的话，请告诉我一声，谢了！：） <br/><br/>　　11.ul标签在Mozilla中默认是有padding值的,而在IE中只有margin有值所以先定义ul{margin:0;padding:0;} &nbsp;<br/><br/>　　就能解决大部分问题 <br/><br/>　　注意事项： <br/><br/>　　1、float的div一定要闭合。 <br/><br/>　　例如：(其中floatA、floatB的属性已经设置为 float:left;)<br/><#div id=&#92;"floatA&#92;" > <br/><br/>　　<#div id=&#92;"floatB&#92;" > <br/><br/>　　<#div id=&#92;"NOTfloatC&#92;" > <br/><br/>　　这里的NOTfloatC并不希望继续平移，而是希望往下排。 <br/><br/>　　这段代码在IE中毫无问题，问题出在FF。原因是NOTfloatC并非float标签，必须将 float标签闭合。 DL.bitsCN.com网管软件下载 <br/><br/>　　在<#div class=&#92;"floatB&#92;"> <br/><br/>　　<#div class=&#92;"NOTfloatC&#92;"> <br/><br/>　　之间加上<#div class=&#92;"clear&#92;"> <br/><br/>　　这个div一定要注意声明位置，一定要放在最恰当的地方，而且必须与两个具有float属性的div同级，之间不能存在嵌套关系，否则会产生异常。 <br/>　　并且将clear这种样式定义为为如下即可：.clear{clear:both;} <br/><br/>　　此外，为了让高度能自动适应，要在wrapper里面加上overflow:hidden; bitsCN.nET中国网管博客 <br/><br/>　　当包含float的box的时候，高度自动适应在IE下无效，这时候应该触发IE的layout私有属性(万恶的IE啊！)用zoom:1;可以做到，这样就达到了兼容。 <br/><br/><br/>　　例如某一个wrapper如下定义：.colwrapper{ 　　<br/>verflow:hidden; <br/><br/>zoom:1; <br/><br/>margin:5px auto;} <br/><br/>2、margin加倍的问题。<br/><br/>　　设置为float的div 在ie下设置的margin会加倍。这是一个ie6都存在的bug。<br/>　　解决方案是在这个div里面加上 display:inline;<br/>例如：<br/><#div id=&#92;"imfloat&#92;"> <br/><br/>　　相应的<span class='wp_keywordlink_affiliate'><a href="http://www.xixis.net/archives/tag/css" title="显示css的所有日志" target="_blank">css</a></span>为<br/>#IamFloat{<br />float:left;<br/>margin:5px;/*IE下理解为10px*/<br />display:inline;/*IE下再理解为5px*/} <br/><br/>　　3、关于容器的包涵关系 <br/><br/>　　很多时候，尤其是容器内有平行布局，例如两、三个float的div时，宽度很容易出现问题。在IE 中，外层的宽度会被内层更宽的div挤破。一定要用Photoshop或者Firework量取像素级的精度。<br/><br />　　4、关于高度的问题 <br/><br/>　　如果是动态地添加内容，高度最好不要定义。浏览器可以自动伸缩，然而如果是静态的内容，高度最好定好。（似乎有时候不会自动往下撑开，不知道具体怎么回事） <br/><br/>　　5、最狠的手段 &#8211; !important; <br/><br/><br/>　　如果实在没有办法解决一些细节问题,可以用这个方法.FF对于&#8221;!important&#8221;会自动优先解析,然而IE则会忽略.如下.tabd1{<br/>background:url(/res /images/up/tab1.gif) no-repeat 0px 0px !important; /*Style for FF*/<br/>background:url(/res/images/up/tab1.gif) no-repeat 1px 0px; /* Style for IE */} 中国网管联盟 <br/><br/>　　值得注意的是，一定要将xxxx !important 这句放置在另一句之上，上面已经提过. <br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xixis.net/archives/summary-css-in-ie-and-firefox-compatibility-under-the.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

