<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Speeding Up Website: all about web performance</title>
	
	<link>http://www.speedingupwebsite.com</link>
	<description>WordPress performance in details</description>
	<lastBuildDate>Wed, 30 Jun 2010 19:54:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/SpeedingUpWebsite" /><feedburner:info uri="speedingupwebsite" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>SpeedingUpWebsite</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>data:URI + mhtml troubles and solutions</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/JYZtWTetDuw/</link>
		<comments>http://www.speedingupwebsite.com/2010/03/26/datauri-mhtml-troubles-and-solutions/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 16:10:32 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Browser Performance]]></category>
		<category><![CDATA[Client Side Performance]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=541</guid>
		<description><![CDATA[
After several posts about data:URI and actual data:URI performance impact let&#8217;s see how this technique can affect website performance or some other sides of website consistency or website speedup issues.
Large resource file size
It&#8217;s the main reason why data:URI + mhtml is used so rarely. Webmasters are afraid of large final file size &#8211; and just [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/03/038.png" alt="data:URI + mhtml troubles" title="data:URI + mhtml troubles" width="550" height="226" class="alignnone size-full wp-image-542" /></p>
<p>After several posts about <a href="http://www.speedingupwebsite.com/2010/01/20/datauri-is-the-next-generation-of-acceleration/">data:URI</a> and actual <a href="http://www.speedingupwebsite.com/2010/01/20/even-faster-styles-with-data-uri/">data:URI performance impact</a> let&#8217;s see how this technique can affect <a href="http://www.webogroup.com/">website performance</a> or some other sides of website consistency or <a href="http://www.webogroup.com/home/site-speedup/">website speedup</a> issues.</p>
<h3>Large resource file size</h3>
<p>It&#8217;s the main reason why data:URI + mhtml is used so rarely. Webmasters are afraid of large final file size &#8211; and just do not include background images in base64 format. There was discussed some ways to prevent large assets of data to be loaded before the content is whon in browser in one of the previous articles &#8211; <a href="http://www.speedingupwebsite.com/2010/01/20/even-faster-styles-with-data-uri/">even faster styles</a>. This approach allows you to delay actual load of resource CSS file, so it won&#8217;t influence much your website load time.</p>
<p>Also here you can very <a href="http://www.speedingupwebsite.com/2010/02/01/remove-unused-styles-make-your-website-lighter/">thoroughly clean up styles</a> or <a href="http://www.speedingupwebsite.com/2010/01/23/css-sprites-revealing-sealed-myster/">create CSS Sprites</a>. Both this ways can help you to reduce drwabacks from large data:URI chunks of data.</p>
<h3>Cross browser compatibility</h3>
<p>data:URI can be used only for IE8 and all modern browsers. For IE7- you need to use either raw background images or mhtml approach. The last one leaks under IE7@Vista, but can be fixed with <a href="http://www.aoao.org.cn/blog/2010/01/fixed-mhtml-ie7-vista/" rel="nofollow">this approach</a> (which is already included into <a href="http://duris.ru/">duris.ru</a> or <a href="http://wordpress.org/extend/plugins/web-optimizer/" rel="nofollow">WEBO Site SpeedUp</a>).</p>
<p>The whole technology is a bit complicated (you need to restrict data:URI images&#8217; size and properly use mhtml to get the best results). But can be integrated for any website.</p>
<h3>Security issues</h3>
<p>The main issue here is related to Firefox. It took <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=358438" rel="nofollow">3.5 years to fix it</a>, but now the main issue with data:URI on SSL-protected websites usage is fixed. The other browsers don&#8217;t have known issues here.</p>
<p>Also there are possible vulnerabilities in data:URI / mhtml parsing (buffer overflow, etc), which must be fixed in browsers before you can completely safely use base64 to present data in your web projects.</p>
<p>Also one of the possible solutions is to include data:URI chunks inside the HTML page, so all data will be encoded properly.</p>
<h3>Performance issues</h3>
<p>data:URI takes much more time to be processed (in comparison to CSS Sprites or raw images) &#8211; about 10x more (for Firefox, for IE &#8211; 2x, for Opera/WebKit almost the same time). So in case of large images&#8217; square (starting from 400&#215;400, or 100k square dots), so you must be careful ibefore you completely convert all graphics to base64.</p>
<p>Before browsers can parse data:URI completely efficiently you can balance graphics between data:URI (+mhtml) and CSS Sprites, so the total performance will be still very high.</p>
<h3>Conclusion</h3>
<p>You can combine background images to data:URI view, but you should know about all drwabacks which can be caused with this performance optimization technique. And all solutions which can be used to prevent them.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>January 23, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/23/css-sprites-revealing-sealed-myster/" title="CSS Sprites: revealing sealed mystery">CSS Sprites: revealing sealed mystery</a> (1)</li><li>February 11, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/11/hacking-timthumb-php-all-the-best-practices/" title="Hacking timthumb.php &#8211; all the best practices">Hacking timthumb.php &#8211; all the best practices</a> (3)</li><li>January 19, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/19/too-many-styles-shrink-them/" title="Too many styles? Shrink them!">Too many styles? Shrink them!</a> (1)</li><li>March 3, 2010 -- <a href="http://www.speedingupwebsite.com/2010/03/03/javascript-combine-and-minify-troubles-and-solutions/" title="JavaScript Combine and Minify &#8211; troubles and solutions">JavaScript Combine and Minify &#8211; troubles and solutions</a> (0)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=JYZtWTetDuw:lc-8Y3Qm0qs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=JYZtWTetDuw:lc-8Y3Qm0qs:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=JYZtWTetDuw:lc-8Y3Qm0qs:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=JYZtWTetDuw:lc-8Y3Qm0qs:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=JYZtWTetDuw:lc-8Y3Qm0qs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=JYZtWTetDuw:lc-8Y3Qm0qs:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=JYZtWTetDuw:lc-8Y3Qm0qs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=JYZtWTetDuw:lc-8Y3Qm0qs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=JYZtWTetDuw:lc-8Y3Qm0qs:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=JYZtWTetDuw:lc-8Y3Qm0qs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=JYZtWTetDuw:lc-8Y3Qm0qs:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/JYZtWTetDuw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/03/26/datauri-mhtml-troubles-and-solutions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/03/26/datauri-mhtml-troubles-and-solutions/</feedburner:origLink></item>
		<item>
		<title>Dynamic CSS / JavaScript files are evil – 8 reasons</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/jKOYK_4DZGM/</link>
		<comments>http://www.speedingupwebsite.com/2010/03/07/dynamic-css-javascript-are-evil-8-reasons/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 20:41:41 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[Server Side Performance]]></category>
		<category><![CDATA[client side cache]]></category>
		<category><![CDATA[combine]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[webo site speedup]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=535</guid>
		<description><![CDATA[
In the prvious posts we stated that dynamic images are bad and how images (from timthumb) can be statified. Let&#8217;s speak today about dynamic CSS / JavaScript files and see what can be done here.
What is dynamic CSS / JavaScript files?
All style sheets and JavaScript calls which has extension not .css or .js (but .php). [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/03/037.png" alt="Dynamic CSS / JavaScript" title="Dynamic CSS / JavaScript" width="550" height="226" class="alignnone size-full wp-image-536" /></p>
<p>In the prvious posts we stated that <a href="http://www.speedingupwebsite.com/2010/01/13/5x-speedup-with-client-side-caching/">dynamic images are bad</a> and how <a href="http://www.speedingupwebsite.com/2010/01/26/statify-dynamic-images-from-timthumb/">images (from timthumb) can be statified</a>. Let&#8217;s speak today about dynamic CSS / JavaScript files and see what can be done here.</p>
<h3>What is dynamic CSS / JavaScript files?</h3>
<p>All style sheets and JavaScript calls which has extension not <code>.css</code> or <code>.js</code> (but <code>.php</code>). As an example you an take a look at <code>gdsr.css.php</code> file (which is a part of <a href="http://wordpress.org/extend/plugins/gd-star-rating/" rel="nofollow">GD Star Rating</a> plugin) &#8211; this one is beter than a common example because it allows client side caching.</p>
<p>So all PHP-based CSS / JavaScript files are dynamic and thus evil. Let&#8217;s see why.</p>
<h3>Reason 1. PHP execution is expensive</h3>
<p>Each ms is valualbe for your website. And dynamic file&#8217; generation costs about 2-3x more expensive that plain (=static) files. This is not very important in comparison to WordPress (or any other CMS) execution time to generate HTML document. But while using strong caching techniques (and creating high performance websites) such costs become valuable.</p>
<h3>Reason 2. PHP files are not cached</h3>
<p>Usually (note: sometimes it&#8217;s not true) dynamic PHP files don&#8217;t set proper client side caching headers (both far future and conditional ones). This is very bad because with every page request takes additional time from server to generate this file and additional time from client browser to load it. There is double drawback here.</p>
<h3>Reason 3. PHP files has GET parameters</h3>
<p>The main reason why sometimes PHP scripts are used to serve CSS or JavaScript content is a feedom to server different content for different initial (GET) parameters. This is very convenient for developers but is not so good for <a href="http://www.webogroup.com/home/">client side performance</a> &#8211; because some proxy servers don&#8217;t cache files with GET parameters in URL (because they can be dynamic), and this leads to slower website load.</p>
<h3>Reason 4. PHP scripts are buggy</h3>
<p>Classical example here is <a href="http://wordpress.org/extend/plugins/featured-content-gallery/" rel="nofollow">Featured Content Gallery</a> which sends CSS files with wrong <code>Content-Type</code> (under certaion conditions). This breaks layout is modern browsers.</p>
<p>Static files (especially on VDS / shared hostings) serving is being tested for years. And all related issues (i.e. <code>Content-Type</code>) were closed long time ago.</p>
<h3>Reason 5. PHP scripts are not gzipped</h3>
<p>It&#8217;s very easy to add <a href="http://www.speedingupwebsite.com/2010/01/08/use-the-gzip-power/">gzip to static files</a> (i.e. with <a href="http://www.speedingupwebsite.com/2010/01/09/static-gzip-or-compression-without-compression/">static gzip</a>). But if you are going to gzip every dynamic PHP script &#8211; you need to alter it manually. And do it with every plugin update (or ask repeatedly authors to add fix for gzip).</p>
<p>Gzip for CSS / JavaScript files can save about 80%, so it&#8217;s a huge drawback.</p>
<h3>Reason 6. PHP scripts are hardly combined</h3>
<p>THe most famous tool &#8211; <a href="http://wordpress.org/extend/plugins/wp-minify/" rel="nofollow">WP-Minify</a> &#8211; to <a href="http://www.speedingupwebsite.com/2010/01/17/less-files-faster-website-but-how-much/">combine static CSS / JavaScript files</a> fails on dynamic (PHP) ones. Because they must be executed first and only then merged with the rest content. So there must be applied more advanced merging techniques or you will have to disable textual files merging at all.</p>
<h3>Reason 7. PHP files are not minified</h3>
<p>Yes, there can be any type of <a href="http://www.speedingupwebsite.com/2010/01/19/too-many-styles-shrink-them/">minify applied to the content of PHP files</a>. But it&#8217;s implemented very rarely (and almost never right). For example there is no place for comments (client side) in such dynamic files &#8211; all they can be left in PHP code.</p>
<h3>Reason 8. Inline code isn&#8217;t included</h3>
<p>It&#8217;s a very simple idea &#8211; as far as we have dynamic file why do we need to include any piece of additional code into HTML document? We can serve all related chunks of data inside the only dynamic file (due to PHP flexibility) &#8211; but actually each plugin includes 2-3 files + a few chunks of data.</p>
<p>There can be some more arguments why developers must think more about performance. And prefer static files (or pre-generated ones) instead of dynamic PHP scripts to serve CSS / JavaScript content. But let&#8217;s see how can we fixe this.</p>
<h3>Solutions</h3>
<p>There can be the only &#8216;true&#8217; way to avoid such dynamic scripts on your website &#8211; just merge them together (or convert) into static files. This is quite painfully but with automated solutions can be like a dream. After this you can simply <a href="http://www.speedingupwebsite.com/2010/01/10/gzip-beyond-possible/">apply gzip</a> or <a href="http://www.speedingupwebsite.com/2010/01/13/5x-speedup-with-client-side-caching/">client side caching</a>.</p>
<p>We reviewed some <a href="http://www.speedingupwebsite.com/2010/01/17/less-files-faster-website-but-how-much/">WordPress plugins to merge scripts</a> and here is the only clear winner &#8211; <a href="http://wordpress.org/extend/plugins/web-optimizer/">WEBO Site SpeedUp</a> (you can check also <a href="http://www.webogroup.com/home/site-speedup-wordpress/comparison/">performance comparison table</a>). So there are only two ways: to perform all actions manually (to improve your <a href="http://www.webogroup.com/">website performance</a>) or prefer an automatic solution. It seems there is no chance to stop using plugins with such dynamic content (or force all authors to use <a href="http://www.webogroup.com/home/site-speedup/installation/">performance optimization best practices</a>).</p>
<h3>Conclusion</h3>
<p>PHP scripts (for CSS / JavaScript content) have many negative features. So you need to use them or&#8230; to fix them manually or automatically.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>February 26, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/26/all-about-wordpress-performance-11-golden-rules/" title="All about WordPress performance &#8211; 11 golden rules">All about WordPress performance &#8211; 11 golden rules</a> (1)</li><li>January 20, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/20/datauri-is-the-next-generation-of-acceleration/" title="data:URI is the next generation of acceleration techniques">data:URI is the next generation of acceleration techniques</a> (2)</li><li>January 19, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/19/too-many-styles-shrink-them/" title="Too many styles? Shrink them!">Too many styles? Shrink them!</a> (1)</li><li>January 17, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/17/less-files-faster-website-but-how-much/" title="Less files &#8211; faster website, but how much?">Less files &#8211; faster website, but how much?</a> (2)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=jKOYK_4DZGM:ClQ9WSOhzlo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=jKOYK_4DZGM:ClQ9WSOhzlo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=jKOYK_4DZGM:ClQ9WSOhzlo:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=jKOYK_4DZGM:ClQ9WSOhzlo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=jKOYK_4DZGM:ClQ9WSOhzlo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=jKOYK_4DZGM:ClQ9WSOhzlo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=jKOYK_4DZGM:ClQ9WSOhzlo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=jKOYK_4DZGM:ClQ9WSOhzlo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=jKOYK_4DZGM:ClQ9WSOhzlo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=jKOYK_4DZGM:ClQ9WSOhzlo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=jKOYK_4DZGM:ClQ9WSOhzlo:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/jKOYK_4DZGM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/03/07/dynamic-css-javascript-are-evil-8-reasons/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/03/07/dynamic-css-javascript-are-evil-8-reasons/</feedburner:origLink></item>
		<item>
		<title>JavaScript Combine and Minify – troubles and solutions</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/Mj-Oo3Mkn_Q/</link>
		<comments>http://www.speedingupwebsite.com/2010/03/03/javascript-combine-and-minify-troubles-and-solutions/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 13:50:28 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=513</guid>
		<description><![CDATA[
We minified and combined all JavaScript files on our website and got about 250ms gain in load speed (or 6%) and website performance. It&#8217;s not so much but JavaScript minify technique can be very dangerous in few cases. Let&#8217;s speak how to reduce number of failures with scripts merging (manual r automatic).
Minify tools
Some troubles are [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/03/036.png" alt="JavaScript combine and minify" title="JavaScript combine and minify" width="550" height="226" class="alignnone size-full wp-image-514" /></p>
<p>We <a href="http://www.speedingupwebsite.com/2010/01/17/less-files-faster-website-but-how-much/">minified and combined all JavaScript files</a> on our website and got about 250ms gain in load speed (or 6%) and <a href="http://www.webogroup.com/">website performance</a>. It&#8217;s not so much but JavaScript minify technique can be very dangerous in few cases. Let&#8217;s speak how to reduce number of failures with scripts merging (manual r automatic).</p>
<h3>Minify tools</h3>
<p>Some troubles are related to improper minify tool selection. There are a few well known tools, let&#8217;s review them.</p>
<ul>
<li><a href="http://www.crockford.com/javascript/jsmin.html" rel="nofollow">JSMin</a> (or <a href="http://crisp.tweakblogs.net/blog/cat/716" rel="nofollow">JSMin+</a>). The first one is very fast and powerful (minify up to 5% over initial gzip). The second one is CPU expensive, but can gives you more minify (it seems about 6-7% over gzipped version). But both tools can be used for sure in any case (due to some reasons of finite states automation &#8211; some JavaScript constructions and variable scopes can&#8217;t be shrinked for sure), and there are some errors (very rarely fortunately).</li>
<li><a href="http://developer.yahoo.com/yui/compressor/" rel="nofollow">YUI Compressor</a>. More robust tool which requires java. Most of hosting environment (PHP-based) don&#8217;t have it (or don&#8217;t allow to execute shell scripts to envelope java calls). The second drawback is that YUI Compressor (due to java virtual machine usage) is very heavy (about 10x more CPU expensive than JSMin). And it give about 6-7% additional compression (with gzip).</li>
<li><a href="http://dean.edwards.name/packer/" rel="nofollow">Packer</a> (from Dean Edwards). It can be very useful if you can&#8217;t <a href="http://www.speedingupwebsite.com/2010/01/09/static-gzip-or-compression-without-compression/">apply gzip for JavaScript files</a> because it creates some kind of archive with JavaScript itself. This adds payload every time with script initialization (with every page) but in case of small libraries can be helpful. This method also often breaks initial JavaScript code (due to not standard-complaint assets). Be careful.</li>
<li><a href="http://code.google.com/closure/compiler/" rel="nofollow">Google Compiler</a>. Very powerful tool (and can save about 10-20% more over YUI Compressor, so up to 10% over gzipped JavaScript file) but is hard to use (a lot of options) and also required java on the server. So it&#8217;s better to use it on a local PC or in production schema.</li>
</ul>
<p>Also you can write your own tool to reduce your scripts (maybe be even faster and more efficiently than all mentioned ones) but you should test all functionality after each such minify action.</p>
<h3>Combine troubles</h3>
<p>The most of WordPress websites has about 5-10 JavaScript files per page. Plus some inline code (which activates such libraries). Finally about 10-15 chunks of JavaScript code. Each of these chunks can be broken (due to bad plugin compatibility, old or non supported browser, or for any other reason). So if we just merge all chunks together we can get completely broken client side logic what is caused by the only JavaScript error (with an old plugin, or conflicts between plugins).</p>
<p>So we can&#8217;t combine JavaScript files for sure at all?</p>
<p>Actually, no, we can&#8217;t. But there are few approaches to inject graceful degradation to JavaScript combine logic.</p>
<h3>Graceful degradation and back compatibility</h3>
<p>First of all we can merge together only JavaScript libraries themselves. Without inline code. This can guarantee (in the most of cases &#8211; because usually there are used generic libraries which have great compatibility) more or less stable work in almost all cases.</p>
<p>But there is one drawback &#8211; we can&#8217;t place for sure merged file before all inline calls or after them. Because some libraries (in this merged package) can be used for further logic. And some can be called with parameters (which are defined a bit earlier), and such parameters must be followed by JavaScript libraries. So we need to have an option &#8211; where to place merged JavaScript file. And <a href="http://wordpress.org/extend/plugins/web-optimizer/" rel="nofollow">WEBO Site SpeedUp</a> has it.</p>
<p>The main approach here is to envelope each JavaScript chunk into try-catch construction. So we can execute all code in combined file and it the case of any failures just inject into the document initial JavaScript call. Final code will be the following</p>
<blockquote><pre>try {
	... content of JavaScript library ...
} catch (e) {
	document.write('initial JavaScript file call');
}
</pre>
</blockquote>
<p>Our combined file (with such constructions) won&#8217;t be loaded &#8216;on fly&#8217; (so <code>document.write</code> won&#8217;t break anything), and try-catch logic will provide required compatibility.</p>
<p>The only drawback here is that try-catch construction &#8216;eats&#8217; CPU. And these expenses will occur on every page load. But this provides a safe way to combine any JavaScript together (of course without any troubles with code order which can be solved only as described above).</p>
<h3>Conclusion</h3>
<p>There are several reefs in JavaScript combine and minify &#8211; minify tools has different features and server side support. Also minified code must be tested after minify. Additionally you should use safe combine approach to be sure that all included JavaScript libraries are being loaded and don&#8217;t conflict with each other.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>February 23, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/23/5-quick-tweaks-for-wordpress-performance/" title="5 quick tweaks for WordPress performance">5 quick tweaks for WordPress performance</a> (1)</li><li>January 14, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/14/caching-everything-caching-everywhere/" title="Caching everything, caching everywhere">Caching everything, caching everywhere</a> (1)</li><li>February 2, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/02/html-minify-to-be-or-not-to-be/" title="HTML minify &#8211; to be or not to be?">HTML minify &#8211; to be or not to be?</a> (4)</li><li>March 26, 2010 -- <a href="http://www.speedingupwebsite.com/2010/03/26/datauri-mhtml-troubles-and-solutions/" title="data:URI + mhtml troubles and solutions">data:URI + mhtml troubles and solutions</a> (0)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Mj-Oo3Mkn_Q:OSxLxMrYWCE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Mj-Oo3Mkn_Q:OSxLxMrYWCE:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=Mj-Oo3Mkn_Q:OSxLxMrYWCE:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Mj-Oo3Mkn_Q:OSxLxMrYWCE:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Mj-Oo3Mkn_Q:OSxLxMrYWCE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=Mj-Oo3Mkn_Q:OSxLxMrYWCE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Mj-Oo3Mkn_Q:OSxLxMrYWCE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=Mj-Oo3Mkn_Q:OSxLxMrYWCE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Mj-Oo3Mkn_Q:OSxLxMrYWCE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Mj-Oo3Mkn_Q:OSxLxMrYWCE:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=Mj-Oo3Mkn_Q:OSxLxMrYWCE:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/Mj-Oo3Mkn_Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/03/03/javascript-combine-and-minify-troubles-and-solutions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/03/03/javascript-combine-and-minify-troubles-and-solutions/</feedburner:origLink></item>
		<item>
		<title>All about WordPress performance – 11 golden rules</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/GTV2rfu8AvU/</link>
		<comments>http://www.speedingupwebsite.com/2010/02/26/all-about-wordpress-performance-11-golden-rules/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 21:09:06 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[Performance Measurement]]></category>
		<category><![CDATA[Server Side Performance]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[client side cache]]></category>
		<category><![CDATA[css sprites]]></category>
		<category><![CDATA[data:URI]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[HTML Sprites]]></category>
		<category><![CDATA[minify]]></category>
		<category><![CDATA[multiple hosts]]></category>
		<category><![CDATA[server side cache]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=508</guid>
		<description><![CDATA[
Let&#8217;s review our achievements for a WordPress-based website and create something like a road map to optimize WordPress performance.
First priority actions

Gzip of die! You must gzip all appropriate files (i.e. HTML, CSS, JavaScript, ICO and Fonts). You can use here &#8216;on fly&#8217; gzip approach (via .htaccess or PHP), then continue with static gzip technique, and [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/035.png" alt="The best WordPress performance rules" title="The best WordPress performance rules" width="550" height="226" class="alignnone size-full wp-image-509" /></p>
<p>Let&#8217;s review our achievements for a WordPress-based website and create something like a road map to <a href="http://www.webogroup.com/home/site-speedup-wordpress/">optimize WordPress performance</a>.</p>
<h3>First priority actions</h3>
<ul>
<li>Gzip of die! You must gzip all appropriate files (i.e. HTML, CSS, JavaScript, ICO and Fonts). You can use here <a href="http://www.speedingupwebsite.com/2010/01/08/use-the-gzip-power/">&#8216;on fly&#8217; gzip approach</a> (via .htaccess or PHP), then continue with <a href="http://www.speedingupwebsite.com/2010/01/09/static-gzip-or-compression-without-compression/">static gzip technique</a>, and review <a href="http://www.speedingupwebsite.com/2010/01/10/gzip-beyond-possible/">some external (and maybe useful) ways to apply gzip</a> for your website. Here you can save <strong>about 20-50% of website size</strong> (it depends on how much images do you have, for this website it was 25%).</li>
<li>Shrink your images. You should review and integrate any of <a href="http://www.speedingupwebsite.com/2010/01/12/amazing-speed-up-with-image-optimization/">image optimization strategy</a> into your blog. Or use some <a href="http://www.speedingupwebsite.com/2010/01/12/online-image-optimization-or-taiming-robots/">advanced optimization tools</a>. Anyway you can save <strong>about 30-40% of website size</strong> here (34% for this website).</li>
<li>Cache everything. You can use both <a href="http://www.speedingupwebsite.com/2010/01/13/5x-speedup-with-client-side-caching/">client side caching</a> (<a href="http://www.speedingupwebsite.com/2010/01/14/caching-everything-caching-everywhere/">even with disabled server-side support for it</a>) and <a href="http://www.speedingupwebsite.com/2010/01/15/40x-speedup-with-server-side-caching-which-one-is-the-best/">server side caching</a> (latter eliminates a huge pack of performance issues with your website &#8211; so just apply it and forget about troubles). These techniques are pretty simple to integrate into the website and cut your traffic and save your visitors&#8217; time. Also this increases your website capacity (just by removing server side expenses). And it&#8217;s about <strong>10-20% speedup</strong> for new visitors.</li>
</ul>
<p>After these 3 steps you will have <a href="http://www.speedingupwebsite.com/2010/01/16/reviewing-speedup-from-basics-to-advanced-techniques/">2-3x accelerated website</a>. And all this can be applied with a few of actions (there is a lot of software to implement this automatically).</p>
<h3>Second-priority actions</h3>
<p>If you think your <a href="http://www.speedingupwebsite.com/2010/01/06/is-my-wordpress-blog-fast-enough-or-not/">website isn&#8217;t fast enough</a> after the previous actions you can case some more client side magic. It&#8217;s more complicated and give you less performance, but is still worth to be implemented.</p>
<ul>
<li><a href="http://www.speedingupwebsite.com/2010/01/19/too-many-styles-shrink-them/">Combine CSS</a> and <a href="http://www.speedingupwebsite.com/2010/01/17/less-files-faster-website-but-how-much/">JavaScript files</a> and minify them. Gzip saved you a lot of traffic but you can save more and reduce number of HTTP requests here. Depending on your website complexity this can give your <strong>10-20% speedup</strong>.</li>
<li>Review applying <a href="http://www.speedingupwebsite.com/2010/01/20/datauri-is-the-next-generation-of-acceleration/">data:URI</a> or <a href="http://www.speedingupwebsite.com/2010/01/23/css-sprites-revealing-sealed-myster/">CSS Sprites</a> technique. To increase efficiency for these techniques you can <a href="http://www.speedingupwebsite.com/2010/01/20/even-faster-styles-with-data-uri/">delay data:URI resource file load</a> or <a href="http://www.speedingupwebsite.com/2010/01/21/add-more-caching-wit-background-images/">convert HTML images to CSS images</a>. Actual result here is <strong>about additional 20-40% speedup</strong>.</li>
<li>Use <a href="http://www.speedingupwebsite.com/2010/01/27/parallelize-images-multiple-domains-in-action/">multiple (mirroring) domains</a> or <a href="http://www.speedingupwebsite.com/2010/01/28/using-cdn-isit-cool/">even CDN</a>. Actual speedup here greatly depends on how you have applied the previous steps. If all was done right &#8211; it&#8217;s <strong>about 5-10%</strong>. If you can apply some of the previous steps &#8211; speedup will be greater, about 20-50%.</li>
<li>Use <a href="http://www.speedingupwebsite.com/2010/01/26/statify-dynamic-images-from-timthumb/">static images instead of dynamic ones</a>. This will reduce server side load.</li>
</ul>
<p>All mentioned steps are not very hard to implement for your website but can give you up to <strong>1.5x additional speedup</strong>. So the total <a href="http://www.webogroup.com/">website performance</a> improvement will be 3-4.5x.</p>
<h3>Third-priority steps</h3>
<p>If you are still not sure about your website high performance (yes, even after 4.5x speedup this can be possible). You can think about the following actions.</p>
<ul>
<li><a href="http://www.speedingupwebsite.com/2010/02/01/remove-unused-styles-make-your-website-lighter/">Remove unused styles</a>. Be careful with CSS &#8211; it can be used on rare internal pages. Actual performance <strong>gain here is 2-5%</strong>.</li>
<li><a href="http://www.speedingupwebsite.com/2010/02/02/html-minify-to-be-or-not-to-be/">Use HTML minify</a>. This will make your website much faster for returned visitors (as far as they have all static resources cached). And add <strong>about 0.5-1%</strong> to website load speed.</li>
<li>Remove blocking advertisement blocks. You can use <a href="http://www.speedingupwebsite.com/2010/02/17/removing-blocking-adsense/">simple delayed load</a> for any ad blocks (i.e. AdSense). This will increase website rendering speed.</li>
<li><a href="http://www.speedingupwebsite.com/2010/02/21/html-sprites-new-weapon-against-http-requests/">Use HTML Sprites</a>. After applied CSS Sprites and multiple hosts this technique won&#8217;t give much. Maybe <strong>additional 2-5%</strong> to website load speed.</li>
</ul>
<p>We don&#8217;t touch <a href="http://www.speedingupwebsite.com/2010/02/03/are-cookie-free-domains-eficien/">cookie-free domains</a> and <a href="http://www.speedingupwebsite.com/2010/02/12/transparent-fixed-block-woes/">website rendering optimization</a> because in most of cases they give you nothing.</p>
<h3>Conclusion</h3>
<p>You can easily get <strong>3.5-5x+ website acceleration</strong> if you implement all these rules. But more than half of actual performance you will get after first 3 simple steps &#8211; gzip, image optimization, and caching.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>January 29, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/" title="Reviewing speedup &#8211; from advanced to extreme website acceleration">Reviewing speedup &#8211; from advanced to extreme website acceleration</a> (0)</li><li>January 16, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/16/reviewing-speedup-from-basics-to-advanced-techniques/" title="Reviewing speedup &#8211; from basics to advanced techniques">Reviewing speedup &#8211; from basics to advanced techniques</a> (1)</li><li>March 7, 2010 -- <a href="http://www.speedingupwebsite.com/2010/03/07/dynamic-css-javascript-are-evil-8-reasons/" title="Dynamic CSS / JavaScript files are evil &#8211; 8 reasons">Dynamic CSS / JavaScript files are evil &#8211; 8 reasons</a> (4)</li><li>February 21, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/21/html-sprites-new-weapon-against-http-requests/" title="HTML Sprites &#8211; new weapon against HTTP requests">HTML Sprites &#8211; new weapon against HTTP requests</a> (2)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=GTV2rfu8AvU:F5ECz4RG2vY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=GTV2rfu8AvU:F5ECz4RG2vY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=GTV2rfu8AvU:F5ECz4RG2vY:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=GTV2rfu8AvU:F5ECz4RG2vY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=GTV2rfu8AvU:F5ECz4RG2vY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=GTV2rfu8AvU:F5ECz4RG2vY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=GTV2rfu8AvU:F5ECz4RG2vY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=GTV2rfu8AvU:F5ECz4RG2vY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=GTV2rfu8AvU:F5ECz4RG2vY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=GTV2rfu8AvU:F5ECz4RG2vY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=GTV2rfu8AvU:F5ECz4RG2vY:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/GTV2rfu8AvU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/02/26/all-about-wordpress-performance-11-golden-rules/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/02/26/all-about-wordpress-performance-11-golden-rules/</feedburner:origLink></item>
		<item>
		<title>5 quick tweaks for WordPress performance</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/jRgaElW7wXc/</link>
		<comments>http://www.speedingupwebsite.com/2010/02/23/5-quick-tweaks-for-wordpress-performance/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 18:45:40 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[Server Side Performance]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[404 page]]></category>
		<category><![CDATA[bandwidth theft]]></category>
		<category><![CDATA[favicon.ico]]></category>
		<category><![CDATA[robots.txt]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=501</guid>
		<description><![CDATA[
After we accelerated our website 3x, 5x, and even 40x let&#8217;s implement some quick tips to add more performance. Actual improvement is hard to measure, but all these tweaks should add not client side performance but reduce server side load (and improve website usability).
Add favicon.ico to the website root
It can be unclear &#8211; why should [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/034.png" alt="Minor WordPress tweaks" title="Minor WordPress tweaks" width="550" height="226" class="alignnone size-full wp-image-502" /></p>
<p>After we <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/">accelerated our website 3x</a>, <a href="http://www.speedingupwebsite.com/2010/01/13/5x-speedup-with-client-side-caching/">5x</a>, and <a href="http://www.speedingupwebsite.com/2010/01/15/40x-speedup-with-server-side-caching-which-one-is-the-best/">even 40x</a> let&#8217;s implement some quick tips to add more performance. Actual improvement is hard to measure, but all these tweaks should add not client side performance but reduce server side load (and improve website usability).</p>
<h3>Add favicon.ico to the website root</h3>
<p>It can be unclear &#8211; why should we use favicon.ico at all, and why should we duplicate it in the root of the website. But most of browsers request not only favicon (website icon) as it&#8217;s defined in HTML code (and located for example in our theme folder) but also  the root icon. And if there is no such file website serves 404 page which is larger, and it takes much more time to serve it than a static favicon.ico.</p>
<p>Please just <strong>place favicon.ico to the website root</strong>.</p>
<h3>Add static 404 page</h3>
<p>WordPress has powerful SEO friendly URLs rewriting logic. But it leads to serve all requests via WordPress core (except static ones). This is provided by the following rules in .htaccess file</p>
<blockquote><pre># BEGIN WordPress
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
&lt;/IfModule&gt;
# END WordPress</pre>
</blockquote>
<p>Every not cached request to your website can be painful. And if you don&#8217;t cache 404 errors (why you should cache them?) &#8211; HTTP requests to not existent resources can put down your website &#8211; but provide no valid visitors.</p>
<p>To create additional template for 404 page &#8211; just put file <code>404.php</code> with proper code (you can copy <code>index.php</code> from this folder and add some changes). In our case the final file is <code>wp-content/themes/basicpress/404.php</code>. You can also add some &#8216;404 not found&#8217; snippets to provide better usability (i.e. a <a href="http://www.google.com/support/webmasters/bin/answer.py?answer=136085">Google 404 widget</a>). Final output will look like the following one.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/034-1.png" alt="404 Not Found Google widget" title="404 Not Found Google widget" width="484" height="113" class="alignnone size-full wp-image-503" /></p>
<p>Please <strong>add 404 page to your website</strong> (maybe even a custom one).</p>
<h3>Redirect RSS feed</h3>
<p>If you are using FeedBurner to collect your readers &#8211; just rewrite all requests there. Why it&#8217;s important? Because if you have hundreds of readers requests to RSS feed on your website will add server side load. And this can be easily eliminated by redirecting all such traffic to FeedBurner which uses its own capacity to manage all RSS requests.</p>
<p>Just add to .htaccess (before mentioned rules above &#8211; before generic redirect to <code>index.php</code>) &#8211; to perform this .</p>
<blockquote><pre>&lt;IfModule mod_rewrite.c&gt;
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} !FeedBurner    [NC]
RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://feeds.feedburner.com/SpeedingUpWebsite [R=302,NC,L]
&lt;/IfModule&gt;</pre>
</blockquote>
<p>Here you should replace <code>SpeedingUpWebsite</code> with your RSS id on FeedBurner. If you are using another aggregator &#8211; just redirect your users on it.</p>
<p>Please <strong>redirect all RSS requests to RSS aggregators</strong>.</p>
<h3>Prevent hotlinks to images</h3>
<p>We can also restrict placing your images on the other websites than the initial one. This will save number of HTTP requests for your server and reduce your traffic (also this can somehow protect your copyright). To implement this technique add the following rules to <code>.htaccess</code> (also before the last chunk of initial WordPress rules &#8211; with <code>index.php</code>).</p>
<blockquote><pre>&lt;IfModule mod_rewrite.c&gt;
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?speedingupwebsite.com/.*$ [NC]
RewriteRule \.(gif|jpg|png|ico|bmp)$ - [F]
&lt;/IfModule&gt;</pre>
</blockquote>
<p>Please <strong>prevent bandwidth theft</strong>.</p>
<h3>Create static robots.txt</h3>
<p>WordPress also handles requests from search engines to <code>robots.txt</code> file. This won&#8217;t hurt your performance much if you leave this file dynamic. But if you looking for extreme performance (or you aware about CPU expenses) &#8211; create a static file identical to current dynamic one.</p>
<p><code>robots</code>.txt file is always located in the website root &#8211; so just copy content and paste to a new file.</p>
<p>Please <strong>create static robots.txt file</strong>.</p>
<h3>Conclusion</h3>
<p>All such performance hacks won&#8217;t increase your <a href="http://www.webogroup.com/">website performance</a> significantly but just make you sure that you manage all its possible weak points.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>February 26, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/26/all-about-wordpress-performance-11-golden-rules/" title="All about WordPress performance &#8211; 11 golden rules">All about WordPress performance &#8211; 11 golden rules</a> (1)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=jRgaElW7wXc:cCktPlKUnMM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=jRgaElW7wXc:cCktPlKUnMM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=jRgaElW7wXc:cCktPlKUnMM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=jRgaElW7wXc:cCktPlKUnMM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=jRgaElW7wXc:cCktPlKUnMM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=jRgaElW7wXc:cCktPlKUnMM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=jRgaElW7wXc:cCktPlKUnMM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=jRgaElW7wXc:cCktPlKUnMM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=jRgaElW7wXc:cCktPlKUnMM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=jRgaElW7wXc:cCktPlKUnMM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=jRgaElW7wXc:cCktPlKUnMM:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/jRgaElW7wXc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/02/23/5-quick-tweaks-for-wordpress-performance/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/02/23/5-quick-tweaks-for-wordpress-performance/</feedburner:origLink></item>
		<item>
		<title>HTML Sprites – new weapon against HTTP requests</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/sj5ztotE98k/</link>
		<comments>http://www.speedingupwebsite.com/2010/02/21/html-sprites-new-weapon-against-http-requests/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 20:31:50 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[csprites]]></category>
		<category><![CDATA[data:URI]]></category>
		<category><![CDATA[HTML Sprites]]></category>
		<category><![CDATA[HTTP requests]]></category>
		<category><![CDATA[webo site speedup]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=462</guid>
		<description><![CDATA[
It&#8217;s a bonus post after our we finished our WordPress optimization Stage 3. We faced troubles with a large amount of HTML images (about 20 for the home page) &#8211; and don&#8217;t have efficient solution to resolve this issue (yes, multiple hosts can fit, but every HTTP request costs for server side about 12-20 ms [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/033.png" alt="HTML Sprites" title="HTML Sprites" width="550" height="226" class="alignnone size-full wp-image-463" /></p>
<p>It&#8217;s a bonus post after our we finished our <a href="http://www.speedingupwebsite.com/2010/02/19/best-practices-performance-does-it-matter/">WordPress optimization Stage 3</a>. We faced troubles with a large amount of HTML images (about 20 for the home page) &#8211; and don&#8217;t have efficient solution to resolve this issue (yes, <a href="http://www.speedingupwebsite.com/2010/01/27/parallelize-images-multiple-domains-in-action/">multiple hosts can fit</a>, but every HTTP request costs for server side about 12-20 ms &#8211; the same value as for cached HTML page).</p>
<h3>The solution</h3>
<p>As you can remember <a href="http://www.speedingupwebsite.com/2010/02/05/fighting-http-requests-combine-images/">we tried cSprites</a> to fix this issue. But it wasn&#8217;t able to create anything on our shared hosting with very limited resources (also there is no option to exclude images or restrict them by dimensions).</p>
<p>But <a href="http://code.google.com/p/web-optimizator/source/detail?r=1322" rel="nofollow">there was added support for HTML Sprites</a> in nightly builds of <a href="http://wordpress.org/extend/plugins/web-optimizer/" rel="nofollow">WEBO Site SpeedUp</a>. And it works (for this website for sure) with limited memory and doesn&#8217;t need a lot of CPU. And we are lucky to have this amazing <a href="/">web performance</a> solution.</p>
<p>Moreover the modern browsers (IE8 + all alternative ones) support <a href="http://www.speedingupwebsite.com/2010/01/20/datauri-is-the-next-generation-of-acceleration/">data:URI technique</a>, so we can insert our 1&#215;1 transparent GIF file as a base64-encoded chunk of data. With gzip over HTML this reduce total number of HTTP requests by 1 and even HTML document size a bit.</p>
<h3>Results</h3>
<p>Let&#8217;s review what was changed with our website. Before applying HTML Sprtes we have the following chart.</p>
<p><img src="http://wss2.2static.it/wp-content/uploads/2010/02/032-1.png" alt="YSlow chart: before" title="YSlow chart: before" width="442" height="269" class="alignnone size-full wp-image-456"/</p>
<p>And after them the following one.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/033-1.png" alt="YSlow chart: after" title="YSlow chart: after" width="443" height="275" class="alignnone size-full wp-image-464" /></p>
<p>We saved 9 HTTP requests but increased overall page size by 330 Kb. Not good &#8211; but it&#8217;s due to the only Sprite image for the whole website. And this should be configurable (also this can restricted by a list of excluded images). But even without this option progress looks very good &#8211; and algorithm is pretty powerful and fast. Final image is 4910×163, and 16 Mb of available memory (we have 32 here, but ~16 can be used by WordPress / WEBO Site SpeedUp core libraries) was enough to create it.</p>
<p>Also right now WEBO Site SpeeUp doesn&#8217;t work with dynamic images, but the core handles other dynamic resources well. So it seems it&#8217;s a question of 1-2 weeks &#8211; and dynamic images (i.e. created via thumb.php) will be added to this functionality.</p>
<h3>Conclusion</h3>
<p>With HTML Sprites (actually CSS Sprites applied to HTML images) we can save about 20-30% requests. In our case it&#8217;s 25%, and the same value for server side expenses &#8211; because we have all resources cached. So right now our website can handle 25% more traffic.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>January 23, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/23/css-sprites-revealing-sealed-myster/" title="CSS Sprites: revealing sealed mystery">CSS Sprites: revealing sealed mystery</a> (1)</li><li>January 21, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/21/add-more-caching-wit-background-images/" title="Add more caching with (background) images">Add more caching with (background) images</a> (0)</li><li>February 26, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/26/all-about-wordpress-performance-11-golden-rules/" title="All about WordPress performance &#8211; 11 golden rules">All about WordPress performance &#8211; 11 golden rules</a> (1)</li><li>January 29, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/" title="Reviewing speedup &#8211; from advanced to extreme website acceleration">Reviewing speedup &#8211; from advanced to extreme website acceleration</a> (0)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=sj5ztotE98k:LjVtzO5ov9U:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=sj5ztotE98k:LjVtzO5ov9U:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=sj5ztotE98k:LjVtzO5ov9U:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=sj5ztotE98k:LjVtzO5ov9U:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=sj5ztotE98k:LjVtzO5ov9U:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=sj5ztotE98k:LjVtzO5ov9U:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=sj5ztotE98k:LjVtzO5ov9U:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=sj5ztotE98k:LjVtzO5ov9U:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=sj5ztotE98k:LjVtzO5ov9U:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=sj5ztotE98k:LjVtzO5ov9U:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=sj5ztotE98k:LjVtzO5ov9U:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/sj5ztotE98k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/02/21/html-sprites-new-weapon-against-http-requests/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/02/21/html-sprites-new-weapon-against-http-requests/</feedburner:origLink></item>
		<item>
		<title>Best practices performance – does it matter?</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/p_-ZzkbYI9w/</link>
		<comments>http://www.speedingupwebsite.com/2010/02/19/best-practices-performance-does-it-matter/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 15:09:09 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[adsense]]></category>
		<category><![CDATA[speedup]]></category>
		<category><![CDATA[styles]]></category>
		<category><![CDATA[yslow]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=454</guid>
		<description><![CDATA[
Well. It&#8217;s the last post from our website performance optimization Stage 3. Now we can say for sure &#8211; it&#8217;s a fast WordPress blog! But what actual gain have we achieved with all these actions? Let&#8217;s review them.
Extreme performance actions

We reduced size of CSS rules. Due to data:URI technique usage this saved us about 75 [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/032.png" alt="Best practices performance" title="Best practices performance" width="550" height="226" class="alignnone size-full wp-image-455" /></p>
<p>Well. It&#8217;s the last post from our <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/">website performance optimization Stage 3</a>. Now we can say for sure &#8211; it&#8217;s a <a href="http://www.speedingupwebsite.com/2010/01/06/is-my-wordpress-blog-fast-enough-or-not/">fast WordPress blog</a>! But what actual gain have we achieved with all these actions? Let&#8217;s review them.</p>
<h3>Extreme performance actions</h3>
<ul>
<li><a href="http://www.speedingupwebsite.com/2010/02/01/remove-unused-styles-make-your-website-lighter/">We reduced size of CSS rules</a>. Due to data:URI technique usage this saved us <strong>about 75 Kb</strong>, or 20% of website size. But it&#8217;s an uncommon result &#8211; usually this step provides nothing in terms of <a href="/">web performance</a>.</li>
<li><a href="http://www.speedingupwebsite.com/2010/02/02/html-minify-to-be-or-not-to-be/">HTML minify</a> saved for us <strong>about 0.6 Kb</strong> for every page (0.15% of not cached website size, and about 11% for returned visitors).</li>
<li><a href="http://www.speedingupwebsite.com/2010/02/03/are-cookie-free-domains-eficien/">Cookie-free domains</a>. <strong>About 10 ms</strong>, or nothing (<a href="http://www.speedingupwebsite.com/2010/01/27/parallelize-images-multiple-domains-in-action/">after multiple hosts usage</a>).</li>
<li><a href="http://www.speedingupwebsite.com/2010/02/05/fighting-http-requests-combine-images/">Static HTTP images</a> reduced website load time by <strong>about 52 ms</strong> (but were not able to efficiently combine HTML images, this seems to be a useful technique after CSS Sprites), or 1% of website load speed.</li>
<li>Then we saved <strong>another 100-200 ms</strong> with removing <a href="http://www.speedingupwebsite.com/2010/02/12/transparent-fixed-block-woes/">transparent fixed block</a>. This relates to page rendering, not actual network load.</li>
<li>Finally we <a href="http://www.speedingupwebsite.com/2010/02/17/removing-blocking-adsense/">delayed all AdSense blocks</a> and got <strong>about 150 ms</strong> (3&#215;50 ms) with not blocking JavaScript. But all this in case if you have any dynamic ads on your blog.</li>
</ul>
<p>So simple sum shows <strong>about 30% speedup</strong> (not 40x, not 5x, not even 2x &#8211; only 1.3x). And almost all of this came from removal of unused data:URI chunks. Usually all actions together will give about 10% speedup. It&#8217;s very little.</p>
<h3>Overall results</h3>
<p>These results can be also confirmed with YSlow. Please compare this image (it was taken at the beginning of Stage 3)</p>
<p><img src="/wp-content/uploads/2010/02/025-2.png" alt="YSlow before Stage 3" title="YSlow before Stage 3" width="463" height="259"/></p>
<p>with this one (the last YSlow chart).</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/032-1.png" alt="Final YSlow chart" title="Final YSlow chart" width="442" height="269" class="alignnone size-full wp-image-456" /></p>
<p>There is actually no difference. The same number of files (we added a few AdSense &#8211; so the latter situation is even worse). But performance didn&#8217;t change significantly. We just tuned our website to handle more advertisement with the same initial speed. There is nothing more.</p>
<h3>Conclusion</h3>
<p>There is no valid reason to integrate to your website <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/">extreme performance best practices</a>. You can just apply <a href="http://www.speedingupwebsite.com/2010/01/08/the-right-way-to-speed-up-your-blog/">some basics</a> and <a href="http://www.speedingupwebsite.com/2010/01/16/reviewing-speedup-from-basics-to-advanced-techniques/">advanced techniques</a>, and stop with this. But if you have heavy blog with a lot of ads &#8211; <a href="http://www.speedingupwebsite.com/2010/02/17/removing-blocking-adsense/">unobtrusive JavaScript</a> or <a href="http://www.speedingupwebsite.com/2010/02/01/remove-unused-styles-make-your-website-lighter/">unused styles removal should help</a>. This conclusion is proven by numerous graphics and tests, so it&#8217;s just your choice &#8211; to waste time for nothing or not <img src='http://www.speedingupwebsite.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>February 17, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/17/removing-blocking-adsense/" title="Removing blocking AdSense">Removing blocking AdSense</a> (7)</li><li>January 8, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/08/the-right-way-to-speed-up-your-blog/" title="The right way to speed up your blog">The right way to speed up your blog</a> (3)</li><li>January 7, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/07/is-my-wordpress-blog-fast-enough-part-2/" title="Is my WordPress blog fast enough? (part 2)">Is my WordPress blog fast enough? (part 2)</a> (4)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=p_-ZzkbYI9w:unDRMKcAXik:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=p_-ZzkbYI9w:unDRMKcAXik:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=p_-ZzkbYI9w:unDRMKcAXik:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=p_-ZzkbYI9w:unDRMKcAXik:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=p_-ZzkbYI9w:unDRMKcAXik:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=p_-ZzkbYI9w:unDRMKcAXik:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=p_-ZzkbYI9w:unDRMKcAXik:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=p_-ZzkbYI9w:unDRMKcAXik:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=p_-ZzkbYI9w:unDRMKcAXik:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=p_-ZzkbYI9w:unDRMKcAXik:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=p_-ZzkbYI9w:unDRMKcAXik:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/p_-ZzkbYI9w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/02/19/best-practices-performance-does-it-matter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/02/19/best-practices-performance-does-it-matter/</feedburner:origLink></item>
		<item>
		<title>Removing blocking AdSense</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/Ho8Y2O-IfGA/</link>
		<comments>http://www.speedingupwebsite.com/2010/02/17/removing-blocking-adsense/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 23:07:10 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[adsense]]></category>
		<category><![CDATA[blocking scripts]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=446</guid>
		<description><![CDATA[
It&#8217;s the last part of our Stage 3 optimization research. And we are going to perform some actions to remove blocking behavior of AdSense blocks (and any other advertisement as well).
What is blocking JavaScript
Here is a very good article from Steve Souders about how JavaScript blocks web page rendering and how this can be prevented. [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/031.png" alt="Removing blocking AdSense" title="Removing blocking AdSense" width="550" height="226" class="alignnone size-full wp-image-447" /></p>
<p>It&#8217;s the last part of our <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/">Stage 3 optimization research</a>. And we are going to perform some actions to remove blocking behavior of AdSense blocks (and any other advertisement as well).</p>
<h3>What is blocking JavaScript</h3>
<p>Here is a very <a href="http://www.stevesouders.com/blog/2009/04/27/loading-scripts-without-blocking/" rel="nofollow">good article from Steve Souders</a> about how JavaScript blocks web page rendering and how this can be prevented. For our website such blocking behavior can be illustrated the following way:</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/031-1.png" alt="Firebug Net Panel before" title="Firebug Net Panel before" width="646" height="198" class="alignnone size-full wp-image-448" /></p>
<p>As you can see here AdSense (<code>googleads.g.doubleclick.net</code>) prevents our pictures to be downloaded (and actually stops page rendering).</p>
<h3>How to prevent it</h3>
<p>We can just move all our JavaScript libraries to the very bottom of the page (all &mdash; counters, jQuery, MooTools, etc, etc). And browser will load them only after the other content of the page will be rendered. Generally it&#8217;s good only if you have some libraries which don&#8217;t perform <code>document.write</code> code. And what is case of Google AdSense?</p>
<p>Almost every dynamic advertisement network (this can be rich media ones, and context ads, and so on) uses <code>document.write</code> to inject a part of DOM tree (it can be also an <code>iframe</code>) directly to advertisement placeholder. In case of iframes this can be tolerably &#8211; because they download all resources in parallel. But browser every time stops to get the initial JavaScript file, and page &#8216;freezes&#8217; for a while. What is not good.</p>
<p>And how can we handle such dynamic ads?</p>
<h3>Dynamic ads &mdash; dynamic unblocking</h3>
<p>First of all we definitely can load ads in the bottom of the page. But we have a trouble here &mdash; we need to move them to initial placeholders. So we can use a piece of JavaScript code to perform this (actually we are just removing blocking behavior, not building a complex system to load all dynamic assets on the web page in a special order).</p>
<p>For example for AdSense we have the following JavaScript code:</p>
<blockquote><pre>&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-xxxxx";
google_ad_slot = "xxxxxxx";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;</pre>
</blockquote>
<p>We need to use here a placeholder with the same height (to prevent content jumping when we inject actual advertisement back). As far as we have here height of 60 pixels we can use</p>
<blockquote><pre>&lt;div id="placeholder" style="height:60px"&gt;&lt;/div&gt;</pre>
</blockquote>
<p>And in the end of our HTML document (just in footer) we should write the following:</p>
<blockquote><pre>&lt;div id="sourcecode"&gt;&lt;script type="text/javascript"&gt;... google code here...
&lt;/script&gt;&lt;/div&gt;

&lt;script type="text/javascript"&gt;(function() {
var a=document.getElementById("sourcecode"),
b=document.getElementById("placeholder").parentNode;
b.innerHTML=b.innerHTML.replace(/
<div id="sourcecode".*?><\/div>/i,a.innerHTML);
a.parentNode.removeChild(a)
}())&lt;/script&gt;</pre>
</blockquote>
<p>The first part of this code just consists of AdSense code (which is listed above) enveloped by a container. The second part is a dynamic replacement our placeholder (with a given height) with our advertisement. If you have several different ads &mdash; you just need to use different pairs of sourcecode/placeholder for them. That&#8217;s all.</p>
<h3>Automation and actual results</h3>
<p>There is the only WordPress plugin which implements the above logic &mdash; it&#8217;s <a href="http://wordpress.org/extend/plugins/web-optimizer/" rel="nofollow">WEBO Site SpeedUp</a>. It has about 40 default patterns for known ads and counters.</p>
<p>Actual result from this magic is non-blocking JavaScript. The figure below shows our website load waterfall. As you can see some advertisements are loaded even after onDOMready event (blue line here) is fired.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/031-2.png" alt="Firebug Net Panel after" title="Firebug Net Panel after" width="580" height="103" class="alignnone size-full wp-image-449" /></p>
<h3>Conclusion</h3>
<p>Depending on ads number and their placement you can significantly improve your website usability and prevent content rendering blocking with AdSense (and any other advertisement) delayed loading.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>February 19, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/19/best-practices-performance-does-it-matter/" title="Best practices performance &#8211; does it matter?">Best practices performance &#8211; does it matter?</a> (0)</li><li>January 17, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/17/less-files-faster-website-but-how-much/" title="Less files &#8211; faster website, but how much?">Less files &#8211; faster website, but how much?</a> (2)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Ho8Y2O-IfGA:96OBwqSp3TQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Ho8Y2O-IfGA:96OBwqSp3TQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=Ho8Y2O-IfGA:96OBwqSp3TQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Ho8Y2O-IfGA:96OBwqSp3TQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Ho8Y2O-IfGA:96OBwqSp3TQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=Ho8Y2O-IfGA:96OBwqSp3TQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Ho8Y2O-IfGA:96OBwqSp3TQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=Ho8Y2O-IfGA:96OBwqSp3TQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Ho8Y2O-IfGA:96OBwqSp3TQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Ho8Y2O-IfGA:96OBwqSp3TQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=Ho8Y2O-IfGA:96OBwqSp3TQ:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/Ho8Y2O-IfGA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/02/17/removing-blocking-adsense/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/02/17/removing-blocking-adsense/</feedburner:origLink></item>
		<item>
		<title>Transparent fixed block woes</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/-2RMJ3zKS4A/</link>
		<comments>http://www.speedingupwebsite.com/2010/02/12/transparent-fixed-block-woes/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 19:44:28 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Browser Performance]]></category>
		<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[Performance Measurement]]></category>
		<category><![CDATA[fixed]]></category>
		<category><![CDATA[position]]></category>
		<category><![CDATA[scroll]]></category>
		<category><![CDATA[speed tracer]]></category>
		<category><![CDATA[transparent]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=436</guid>
		<description><![CDATA[
With this small post we are going to review actual performance of using transparent blocks on your website. As you remember we installed a small WordPress plugin to track MySQL / server side generation time of every HTML page. It&#8217;s fixed to the right top corner and has a bit transparent background (opacity: 0.8). For [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=9.0" /></div><div>Rating: 9.0/<strong>10</strong> (1 vote cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/030.png" alt="Transparent fixed block performance" title="Transparent fixed block performance" width="550" height="226" class="alignnone size-full wp-image-437" /></p>
<p>With this small post we are going to review actual performance of using transparent blocks on your website. As you remember we <a href="http://www.speedingupwebsite.com/2010/01/06/is-my-wordpress-blog-fast-enough-or-not/">installed a small WordPress plugin</a> to track MySQL / server side generation time of every HTML page. It&#8217;s fixed to the right top corner and has a bit transparent background (<code>opacity: 0.8</code>). For IE it degrades gracefully to <code>position: absolute</code> (it seems without transparency). So for this browser all is OK.</p>
<p>What is wrong with the modern browsers (Firefox, Opera, Safari, Chrome) here?</p>
<h3>Actual performance of transparent + fixed</h3>
<p>To trace rendering performance (yes, we have never covered this in the previous topics, but it seems for now it has almost the same value as HTTP performance &#8211; number of requests and amount of data) we need some tools. We are not going to review them now (you can check this good post <a href="http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/" rel="nofollow">from Stoyan Stefanov about rendering tracing</a>). As far as we are going to analyze modern browsers &#8211; we need <a href="https://chrome.google.com/extensions/detail/ognampngfcbddbfemdapefohjiobgbdl" rel="nofollow">Speed Tracer for Chrome</a>.</p>
<p>Let&#8217;s run it and record <a href="/">web performance</a> through scrolling the home (or any other) page of our website.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/030-1.png" alt="CPU expenses on transparent fixed block" title="CPU expenses on transparent fixed block" width="400" height="293" class="alignnone size-full wp-image-440" /></p>
<p>As you can see we have dozens of rendering events each takes about 80 ms, and this completely load our CPU capacity. So website looks like &#8217;sluggish&#8217; (but there are all resources loaded at that moment).</p>
<h3>Removing performance bottleneck</h3>
<p>Lucky we &#8211; we know what is slow here &#8211; combination of transparent and fixed CSS rules for stats block. If you are going to understand what&#8217;s wrong with your website &#8211; you maybe need to completely debug all mark-up. It can take a lot of time.</p>
<p>So let&#8217;s remove <code>position: fixed</code> (just replace it with <code>position: absolute</code>) for this widget. We will have the following graphics.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/030-2.png" alt="Performanc without fixed block" title="Performanc without fixed block" width="434" height="344" class="alignnone size-full wp-image-441" /></p>
<p>Wow! Our CPU load has eliminated. And now web pages are being rendered very quickly.</p>
<h3>Conclusion</h3>
<p>If you are going to use combination of <code>position: fixed</code> and <code>opacity</code> &#8211; don&#8217;t do this. it breaks any fast website and will waste CPU of your users. Also please be careful with <code>position: fixed</code> itself &#8211; as far as browsers have to re-render it with each scrolling (and it can be hardly cached as pre-rendered picture), it will be very costly.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=9.0" /></div><div>Rating: 9.0/<strong>10</strong> (1 vote cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>January 27, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/27/parallelize-images-multiple-domains-in-action/" title="Parallelize images &#8211; multiple domains in action">Parallelize images &#8211; multiple domains in action</a> (0)</li><li>January 16, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/16/reviewing-speedup-from-basics-to-advanced-techniques/" title="Reviewing speedup &#8211; from basics to advanced techniques">Reviewing speedup &#8211; from basics to advanced techniques</a> (1)</li><li>January 12, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/12/amazing-speed-up-with-image-optimization/" title="Amazing speedup with image optimization">Amazing speedup with image optimization</a> (2)</li><li>January 8, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/08/the-right-way-to-speed-up-your-blog/" title="The right way to speed up your blog">The right way to speed up your blog</a> (3)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=-2RMJ3zKS4A:LwrAhmR7rQY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=-2RMJ3zKS4A:LwrAhmR7rQY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=-2RMJ3zKS4A:LwrAhmR7rQY:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=-2RMJ3zKS4A:LwrAhmR7rQY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=-2RMJ3zKS4A:LwrAhmR7rQY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=-2RMJ3zKS4A:LwrAhmR7rQY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=-2RMJ3zKS4A:LwrAhmR7rQY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=-2RMJ3zKS4A:LwrAhmR7rQY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=-2RMJ3zKS4A:LwrAhmR7rQY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=-2RMJ3zKS4A:LwrAhmR7rQY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=-2RMJ3zKS4A:LwrAhmR7rQY:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/-2RMJ3zKS4A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/02/12/transparent-fixed-block-woes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/02/12/transparent-fixed-block-woes/</feedburner:origLink></item>
		<item>
		<title>Hacking timthumb.php – all the best practices</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/L9a0PRJrLqA/</link>
		<comments>http://www.speedingupwebsite.com/2010/02/11/hacking-timthumb-php-all-the-best-practices/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 00:55:57 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[Server Side Performance]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[client side cache]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[static images]]></category>
		<category><![CDATA[timthumb.php]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=430</guid>
		<description><![CDATA[
We discussed in some previous posts what WordPress performance optimization can be achieved from simple hacks in timthumb.php library (or just thumb.php &#8211; it depends on current WordPress theme). Let&#8217;s bring them all together and review once more.
What is a timthumb.php library?
timthumb.php is a small open source library which is aimed to provide resized copies [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/029.png" alt="Hacking timthumb.php" title="Hacking timthumb.php" width="550" height="226" class="alignnone size-full wp-image-431" /></p>
<p>We discussed in some previous posts what <a href="http://www.speedingupwebsite.com/2010/01/08/the-right-way-to-speed-up-your-blog/">WordPress performance optimization</a> can be achieved from simple hacks in <code>timthumb.php</code> library (or just <code>thumb.php</code> &#8211; it depends on current WordPress theme). Let&#8217;s bring them all together and review once more.</p>
<h3>What is a <code>timthumb.php</code> library?</h3>
<p><code>timthumb.php</code> is a small <a href="http://code.google.com/p/timthumb/" rel="nofollow">open source library</a> which is aimed to provide resized copies of given images. It handles several formats (PGN, GIF, JPEG) and can be configured via 4 parameters &#8211; width, height, zoom crop, quality. It&#8217;s very useful and simple enough. But sometimes it causes severe <a href="http://www.webogroup.com/">web performance</a> issues.</p>
<p>This library usually is located somewhere in you theme folder (directly inside it or maybe inside libraries subfolder).</p>
<h3>Enable cache</h3>
<p><a href="http://www.speedingupwebsite.com/2010/01/12/amazing-speed-up-with-image-optimization/">While we were playing with images&#8217; optimization</a> we found that there can be no cache enabled in <code>timthumb.php</code>. So please check around line 45 &#8211; there must be </p>
<blockquote><pre>check_cache....</pre>
</blockquote>
<p>uncommented (without <code>#</code> or <code>//</code> in the beginning of this line). If it&#8217;s commented &#8211; remove comment. This reduces server side load with every image about 5 times (i.e. from 100ms to 20ms).</p>
<h3>Change cache folder</h3>
<p>Usually cache folder for <code>timthumb.php</code> isn&#8217;t writable. It&#8217;s better (also due to the following points) to re-assign cache folder to uploads where all images from blog posts are located. To perform this please</p>
<ol>
<li>Calculate depth level of timthumb.php library. I.e. it&#8217;s located inside <code>/wp-content/themes/basicpress/</code> folder &#8211; depth level is 3, in case of <code>/wp-content/themes/basicpress/common/libs/</code> &#8211; 5.</li>
<li>Change cache_folder to proper number of repeating <code>../</code> + <code>uploads/</code>. Number of <code>../</code> must be equal depth level &#8211; 1. For eample in case of <code>/wp-content/themes/basicpress/</code> cache_folder must be equal to <code>../../uploads/</code>.</li>
</ol>
<p>Of course you can just set correct (maybe even 0777) rights for default cache directory to make caching working.</p>
<h3>Set maximum compression</h3>
<p>Last parameter in PNG transformation is actually not quality but compression level. So we can re-define it to get minimum default images&#8217; size. Please find near the line 174</p>
<blockquote><pre>$quality = floor($quality * 0.09);</pre>
</blockquote>
<p>and as the next string just add</p>
<blockquote><pre>$quality = 9;</pre>
</blockquote>
<p>This will turn maximum compression for resized PNG images ON.</p>
<h3>Set client side caching</h3>
<p>According to the <a href="http://www.speedingupwebsite.com/2010/01/13/5x-speedup-with-client-side-caching/">post about client side caching</a> let&#8217;s find approximately a line 317 (with header <code>Cache-Control</code>) and set it to</p>
<blockquote><pre>header("Cache-Control: max-age=315360000,public");</pre>
</blockquote>
<p>Then for the next line (maybe 318, with Expires header) increase cache timeout to 315360000:</p>
<blockquote><pre>header("Expires: " . gmdate("D, d M Y H:i:s", time() + 315360000) . "GMT");</pre>
</blockquote>
<h3>Set static redirects</h3>
<p>Yes, it was the post about changing our <a href="http://www.speedingupwebsite.com/2010/01/26/statify-dynamic-images-from-timthumb/">dynamic nature of images to a static one</a>. There are a lot of actions, but this can significantly decrease server side load for your blog (after HTML caching applied).</p>
<h3>Eliminate dynamic images</h3>
<p>And the last part is <a href="http://www.speedingupwebsite.com/2010/02/05/fighting-http-requests-combine-images/">how to eliminate dynamic images</a> from you blog (maybe not completely, but a major part of them). We need to set proper dimensions in our WordPress settings<br />
<img src="http://wss1.2static.it/wp-content/uploads/2010/02/028-1.png" alt="Settings - Media" title="Settings - Media" width="491" height="262" class="alignnone size-full wp-image-421"/><br />
And then just replace dynamic images&#8217; calls in the source code to the static ones. Please <a href="http://www.speedingupwebsite.com/2010/02/05/fighting-http-requests-combine-images/">check the complete manual</a>.</p>
<h3>Conclusion</h3>
<p><code>timthumb.php</code> library can be a performance disaster for your WordPress website. But it can be highly tuned and optimized so overall side effect will be very small.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>February 5, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/05/fighting-http-requests-combine-images/" title="Fighting HTTP requests &#8211; combine images">Fighting HTTP requests &#8211; combine images</a> (0)</li><li>January 14, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/14/caching-everything-caching-everywhere/" title="Caching everything, caching everywhere">Caching everything, caching everywhere</a> (1)</li><li>March 7, 2010 -- <a href="http://www.speedingupwebsite.com/2010/03/07/dynamic-css-javascript-are-evil-8-reasons/" title="Dynamic CSS / JavaScript files are evil &#8211; 8 reasons">Dynamic CSS / JavaScript files are evil &#8211; 8 reasons</a> (4)</li><li>February 26, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/26/all-about-wordpress-performance-11-golden-rules/" title="All about WordPress performance &#8211; 11 golden rules">All about WordPress performance &#8211; 11 golden rules</a> (1)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=L9a0PRJrLqA:ar48pIFPj2c:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=L9a0PRJrLqA:ar48pIFPj2c:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=L9a0PRJrLqA:ar48pIFPj2c:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=L9a0PRJrLqA:ar48pIFPj2c:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=L9a0PRJrLqA:ar48pIFPj2c:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=L9a0PRJrLqA:ar48pIFPj2c:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=L9a0PRJrLqA:ar48pIFPj2c:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=L9a0PRJrLqA:ar48pIFPj2c:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=L9a0PRJrLqA:ar48pIFPj2c:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=L9a0PRJrLqA:ar48pIFPj2c:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=L9a0PRJrLqA:ar48pIFPj2c:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/L9a0PRJrLqA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/02/11/hacking-timthumb-php-all-the-best-practices/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/02/11/hacking-timthumb-php-all-the-best-practices/</feedburner:origLink></item>
		<item>
		<title>Fighting HTTP requests – combine images</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/1yTAv2dN0WE/</link>
		<comments>http://www.speedingupwebsite.com/2010/02/05/fighting-http-requests-combine-images/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 23:13:38 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Performance Measurement]]></category>
		<category><![CDATA[Server Side Performance]]></category>
		<category><![CDATA[csprites]]></category>
		<category><![CDATA[static images]]></category>
		<category><![CDATA[timthumb.php]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=419</guid>
		<description><![CDATA[
Just to remember: it&#8217;s our optimization journey Stage 3. And we are trying to extremely reduce amount of data / number of HTTP requests. We have already tried to remove unused styles, minify HTML, and use cookie-free domains. And saved about 75 Kb of data (mainly from styles).
Analyzing HTTP requests
We totally have 25 HTTP requests [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/028.png" alt="" title="028" width="550" height="226" class="alignnone size-full wp-image-420" /></p>
<p>Just to remember: it&#8217;s our <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/">optimization journey Stage 3</a>. And we are trying to extremely reduce amount of data / number of HTTP requests. We have already tried <a href="http://www.speedingupwebsite.com/2010/02/01/remove-unused-styles-make-your-website-lighter/">to remove unused styles</a>, <a href="http://www.speedingupwebsite.com/2010/02/02/html-minify-to-be-or-not-to-be/">minify HTML</a>, and <a href="http://www.speedingupwebsite.com/2010/02/03/are-cookie-free-domains-eficien/">use cookie-free domains</a>. And saved about 75 Kb of data (mainly from styles).</p>
<h3>Analyzing HTTP requests</h3>
<p>We totally have 25 HTTP requests (only 23 are to our website, 1 is Google Analytics library + 1 is Google Analytics counter).</p>
<p><img src="http://wss.2static.it/wp-content/uploads/2010/02/026-2.png" alt="YSlow chart" title="YSlow chart" width="448" height="269" class="alignnone size-full wp-image-405"/></p>
<p>It&#8217;s too much. But we can&#8217;t just move 50+ Kb of CSS and JavaScript code to <strong>each</strong> HTML document &#8211; it&#8217;s better to leave them separated to improve caching. We lose 2 HTTP requests but gain 50 Kb with every returned page view.</p>
<p>We can also do actually nothing with CSS images &#8211; they are too big to be included anywhere. Maybe combine them into 1 CSS Sprite? But it seems our hosting memory restriction (32 Mb only) won&#8217;t allow us to perform this.</p>
<p>We can do nothing with favicon. Yes, we can include it into HTML (as base64-encoded data). But most of browsers will still request the root <code>favicon.ico</code> file (just to be sure there is a website icon). And <a href="http://developer.yahoo.com/performance/rules.html#favicon" rel="nofollow">we can&#8217;t do anything here</a>. We have already gzipped it (with <a href="http://www.speedingupwebsite.com/2010/01/09/static-gzip-or-compression-without-compression/">static gzip</a>) &#8211; and that&#8217;s enough.</p>
<p>Also we can&#8217;t eliminate a request to HTML document. Yes. Really.</p>
<h3>Handling images</h3>
<p>Why HTTP requests are bad? They are bad not only due to client side performance but also with server side expenses. We use cheap shared hosting and static files <a href="http://www.speedingupwebsite.com/2010/01/26/statify-dynamic-images-from-timthumb/">take about 12 ms from server to be loaded</a>. Not good because 23*12 = 276 ms. And we can handle only 4 new visitors a second to our website (but about 10-20 returned or continued posts reading visitors). And we need to somehow improve this number.</p>
<p>OK. Simple answer is &#8211; use <a href="http://en.wikipedia.org/wiki/Image_maps" rel="nofollow">HTML Sprites / Image Maps</a>. But <a href="http://www.speedingupwebsite.com/2010/01/23/css-sprites-revealing-sealed-myster/">we tried cSprites</a> (it seems it&#8217;s the only automated solution for WordPress) &#8211; it can&#8217;t deal properly with our memory limit. Also we can&#8217;t configure it flexibly enough (to exclude some images- not their types, &#8211;  and to restrict images size, and so on).</p>
<p>Well. No way? Hmm. It seems we need to invent some solution. Because we have 10 posts images for the home page + 3 slide images &#8212; all of them can be merged together once a day (yes, we have 1 blog post a day). Total square of these images is</p>
<blockquote><pre>158 * 158 * 10 + 48 * 48 * 3 = 256552 square pixels</pre>
</blockquote>
<p>GD library (PHP extension to handle image processing) uses about 10 bytes per pixel (not more, maybe less). It&#8217;s about 2.5 Mb of memory &#8211; to perform HTML Sprite creation with these 13 images. Wow! We definitely need to develop a plugin or any other tool.</p>
<h3>Static images</h3>
<p>But before we start with such tool let&#8217;s make images on our website a bit more static. Actually we have 2 different pair sizes for thumbnails &#8211; 158&#215;158 (used in posts&#8217; list) and 48&#215;48 (in slide show) &#8211; but we can affect automatic creation of only one of them. Let it be the largest one &#8211; 158&#215;158. So we can simply to go <code>Settings -&gt; Media</code> in our WordPress admin interface and set proper thumbnails sizes there.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/028-1.png" alt="Settings - Media" title="Settings - Media" width="491" height="262" class="alignnone size-full wp-image-421" /></p>
<p><strong>Note:</strong> before the next step please don&#8217;t forget to prepare <code>-158x158</code> files for your blog posts &#8211; just because changes in Media don&#8217;t affect already created images. If you already have <a href="http://www.speedingupwebsite.com/2010/01/26/statify-dynamic-images-from-timthumb/">static images from timthumb library</a> &#8211; you should simply copy <code>-158-158-1-80</code> ones to <code>-158x158</code>.</p>
<p>Well. Here we are going to change our templates (it&#8217;s BasicPress theme). You need to touch files <code>index.php</code>, and <code>archive.php</code>. We are replacing call to timthumb with proper static image. So lets&#8217; remove this chunks of data:</p>
<blockquote><pre>&lt;?php bloginfo( 'template_directory' ); ?&gt;/timthumb.php?src=</pre>
</blockquote>
<p>and</p>
<blockquote><pre>&amp;amp;w=158&amp;amp;h=158&amp;amp;zc=1</pre>
</blockquote>
<p>(the last one can contain different dimensions, i.e. <code>w=158&amp;amp;h=158</code> and quality parameter after <code>zc</code>, but you should remove all this request string).</p>
<p>So for images you will have something like the following</p>
<blockquote><pre>&lt;img src="&lt;?php echo get_post_meta( $post->ID, "image_value", true ); ...</pre>
</blockquote>
<p>Here we need to change this raw image with minified one (not to send to visitors huge scaled images).</p>
<blockquote><pre>&lt;img src="&lt;?php echo preg_replace("/.png$/i", "", get_post_meta( $post->ID, "image_value", true )); ?&gt;-158x158.png ...</pre>
</blockquote>
<p>Please note: we also added <code>-158x158.png</code> to this value (and removed <code>.png</code> from its end). If you used JPEG images with PNG &#8211; you should alter this a bit.</p>
<p>So initial piece of code </p>
<blockquote><pre>&lt;?php bloginfo( 'template_directory' ); ?>/timthumb.php?src=&lt;?php echo get_post_meta( $post->ID, "image_value", true ); ?&gt;&amp;amp;w=158&amp;amp;h=158&amp;amp;zc=1</pre>
</blockquote>
<p>is transformed to</p>
<blockquote><pre>&lt;?php echo preg_replace("/.png$/i", "", get_post_meta( $post->ID, "image_value", true )); ?&gt;-158x158.png</pre>
</blockquote>
<p>And this is applied to all images with required dimensions.</p>
<p>Please do not touch other images than initial chosen dimensions (in our case it&#8217;s 158&#215;158  &#8211; in your case they can be different). Leave them dynamic (in our case we can allow us one more hack &#8211; remove dynamic images from the large ones in slide show as far as we create all large images exactly 550&#215;226).</p>
<h3>Results</h3>
<p>Here we (with the help of internal WordPress tools) replaced almost all of dynamic images with static ones. This should help us to merge them together and make our website more robust. Here we have saved about <strong>13&#215;4 ms = 52 ms</strong> with every new visit. And this is 2.5x more than expenses <a href="http://www.speedingupwebsite.com/2010/01/15/40x-speedup-with-server-side-caching-which-one-is-the-best/">to serve a HTML document for our website</a>.</p>
<p><a href="http://www.webogroup.com/home/site-speedup/">Client side speedup</a> isn&#8217;t as large as server side one (because he have highly parallelized load flows) &#8211; it&#8217;s about 4-10 ms here. Or nothing.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>February 11, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/11/hacking-timthumb-php-all-the-best-practices/" title="Hacking timthumb.php &#8211; all the best practices">Hacking timthumb.php &#8211; all the best practices</a> (3)</li><li>February 21, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/21/html-sprites-new-weapon-against-http-requests/" title="HTML Sprites &#8211; new weapon against HTTP requests">HTML Sprites &#8211; new weapon against HTTP requests</a> (2)</li><li>January 23, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/23/css-sprites-revealing-sealed-myster/" title="CSS Sprites: revealing sealed mystery">CSS Sprites: revealing sealed mystery</a> (1)</li><li>January 21, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/21/add-more-caching-wit-background-images/" title="Add more caching with (background) images">Add more caching with (background) images</a> (0)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=1yTAv2dN0WE:J7It6BNOXf8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=1yTAv2dN0WE:J7It6BNOXf8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=1yTAv2dN0WE:J7It6BNOXf8:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=1yTAv2dN0WE:J7It6BNOXf8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=1yTAv2dN0WE:J7It6BNOXf8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=1yTAv2dN0WE:J7It6BNOXf8:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=1yTAv2dN0WE:J7It6BNOXf8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=1yTAv2dN0WE:J7It6BNOXf8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=1yTAv2dN0WE:J7It6BNOXf8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=1yTAv2dN0WE:J7It6BNOXf8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=1yTAv2dN0WE:J7It6BNOXf8:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/1yTAv2dN0WE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/02/05/fighting-http-requests-combine-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/02/05/fighting-http-requests-combine-images/</feedburner:origLink></item>
		<item>
		<title>Are cookie-free domains efficient?</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/LR1r1uytjQw/</link>
		<comments>http://www.speedingupwebsite.com/2010/02/03/are-cookie-free-domains-eficien/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 23:43:43 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[multiple hosts]]></category>
		<category><![CDATA[page speed]]></category>
		<category><![CDATA[webo site speedup]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=411</guid>
		<description><![CDATA[
This is the third post in our website performance optimization journey Stage 3. In the previous parts we reduced data:URI (CSS) size and minified HTML. Now we are going to move all resources to cookie-free domains and somehow measure the difference.
Basics
Why cookie-free domains are good? Here is a very detailed investigation how cookie (headers) size [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/027.png" alt="Reducing cookie weight" title="Reducing cookie weight" width="550" height="226" class="alignnone size-full wp-image-412" /></p>
<p>This is the third post in our <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/">website performance optimization journey Stage 3</a>. In the previous parts we <a href="http://www.speedingupwebsite.com/2010/02/01/remove-unused-styles-make-your-website-lighter/">reduced data:URI (CSS) size</a> and <a href="http://www.speedingupwebsite.com/2010/02/02/html-minify-to-be-or-not-to-be/">minified HTML</a>. Now we are going to move all resources to cookie-free domains and somehow measure the difference.</p>
<h3>Basics</h3>
<p>Why cookie-free domains are good? Here is <a href="http://www.die.net/musings/page_load_time/" rel="nofollow">a very detailed investigation</a> how cookie (headers) size can affect website load speed. In our case cookie are not so big (their actual size is <script type="text/javascript">document.write(document.cookie.length)</script> bytes) but we can still save some visitors time with their minify.</p>
<p>How can we minify cookie size? Well, actually no way. But we can eliminate cookie usage for static assets if we place such assets to different (from our website) domains. Something like <code>static-youwebsite.com</code> (note, it&#8217;s not <code>static.yourwebsite.com</code> &#8211; another sub-domain, but another first-level domain).</p>
<p>And how can we implement such solution?</p>
<h3>Implementation</h3>
<p>Actually we need either to register another domain and mirror our <a href="http://www.speedingupwebsite.com/2010/01/26/statify-dynamic-images-from-timthumb/">static resources</a> to it. Or use some ready solutions (such as <a href="http://www.speedingupwebsite.com/2010/01/14/caching-everything-caching-everywhere/">Google CDN</a> or <a href="http://2static.it/" rel="nofollow">2static.it</a>, or <a href="http://www.speedingupwebsite.com/2010/01/28/using-cdn-isit-cool/">another CDN</a>). The last one actually offer you a mirror domains which you can point to your website and get all benefits from <a href="http://www.speedingupwebsite.com/2010/01/27/parallelize-images-multiple-domains-in-action/">parallel images loading</a> without sub-domains usage.</p>
<p>We are using WEBO Site SpeedUp (as an external application, but <a href="http://wordpress.org/extend/plugins/web-optimizer/" rel="nofollow">WordPress plugin</a> has the same features) to distribute images through multiple domains (not sub-domains but completely external domains).</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/027-1.png" alt="Enable cookie-freee hosts" title="Enable cookie-freee hosts" width="292" height="186" class="alignnone size-full wp-image-413" /></p>
<p>Here we have used 3 static domains (what is quite enough for our 20 images). And how much have we got?</p>
<p>Actual load speed should be improved very slightly. And it can be hardly measured. As far as we have not so big cookie size &#8211; and about 3 chunks in page load (due to multiple domains usage) forecasted gain should be about 3 * 3 ms = 10 ms. So it&#8217;s less than average fluctuation in load speed measurement (100 ms). Right now our website for a new visitor is being loaded in 3.7 seconds, so we can&#8217;t get anything from cookie-free domains usage.</p>
<p>Even if we would have cookie size about 4 Kb with multiple domains we get about 100-150 ms gain, What is actually about 2-3% speedup and doesn&#8217;t worth to be implemented.</p>
<h3>Small bonus</h3>
<p>We have also added dimensions for our HTML images (to improve Page Speed grade because we can&#8217;t improve YSlow grade from 90 &#8211; can&#8217;t affect our website headers due to absence of <code>mod_headers</code> here, but can affect number of static assets &#8211; this will be covered in the next posts).</p>
<p>So how to implement dimensions setting for Basicpress theme (and maybe some others with timthumb library). We are going to <code>wp-content/themes/basicpress/index.php</code> and on the line 8 (where <code>img</code> is inserted) replace</p>
<blockquote><pre> border="0"</pre>
</blockquote>
<p>with</p>
<blockquote><pre> width="158" height="158"</pre>
</blockquote>
<p>Maybe better will be done this via CSS usage. But it works anyway.</p>
<p>Also we should make almost the same changes in <code>wp-content/themes/basicpress/header.php</code> (please take into according actual image sizes, i.e. for slide show we have 550&#215;226 and 48&#215;48 &#8211; for bigger and smaller ones. We are not touching <code>wp-content/themes/basicpress/sidebar.php</code> because we are going to move image from Popular posts widget to our CSS Sprites / CSS background images.</p>
<p>After this piece of magic we will have significantly less warnings about not set images&#8217; dimensions in Google Page Speed extension for Firebug/Firefox (and a bit improved usability for our website). ANd its grade is now 96/100. That&#8217;s great!</p>
<h3>Conclusion</h3>
<p>After multiple domains usage cookie-free domains are not efficient (even if you have large amount of cookies per each HTTP request). Moreover if you have small cookie size &#8211; you will get no actual speedup after this technique implementation.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>January 29, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/" title="Reviewing speedup &#8211; from advanced to extreme website acceleration">Reviewing speedup &#8211; from advanced to extreme website acceleration</a> (0)</li><li>January 27, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/27/parallelize-images-multiple-domains-in-action/" title="Parallelize images &#8211; multiple domains in action">Parallelize images &#8211; multiple domains in action</a> (0)</li><li>March 7, 2010 -- <a href="http://www.speedingupwebsite.com/2010/03/07/dynamic-css-javascript-are-evil-8-reasons/" title="Dynamic CSS / JavaScript files are evil &#8211; 8 reasons">Dynamic CSS / JavaScript files are evil &#8211; 8 reasons</a> (4)</li><li>February 26, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/26/all-about-wordpress-performance-11-golden-rules/" title="All about WordPress performance &#8211; 11 golden rules">All about WordPress performance &#8211; 11 golden rules</a> (1)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=LR1r1uytjQw:_C_SyXQEZxU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=LR1r1uytjQw:_C_SyXQEZxU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=LR1r1uytjQw:_C_SyXQEZxU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=LR1r1uytjQw:_C_SyXQEZxU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=LR1r1uytjQw:_C_SyXQEZxU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=LR1r1uytjQw:_C_SyXQEZxU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=LR1r1uytjQw:_C_SyXQEZxU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=LR1r1uytjQw:_C_SyXQEZxU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=LR1r1uytjQw:_C_SyXQEZxU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=LR1r1uytjQw:_C_SyXQEZxU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=LR1r1uytjQw:_C_SyXQEZxU:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/LR1r1uytjQw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/02/03/are-cookie-free-domains-eficien/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/02/03/are-cookie-free-domains-eficien/</feedburner:origLink></item>
		<item>
		<title>HTML minify – to be or not to be?</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/Q4vmUUR8B1o/</link>
		<comments>http://www.speedingupwebsite.com/2010/02/02/html-minify-to-be-or-not-to-be/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 22:34:38 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[minify]]></category>
		<category><![CDATA[w3 total cache]]></category>
		<category><![CDATA[WEBO Site Speed]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=403</guid>
		<description><![CDATA[
Let&#8217;s review today such a contradictory point in website acceleration as HTML minify. It&#8217;s one of our steps to bring extreme performance to our website. And it can reduce load time not only for the first-time visitors, but also for returned ones and if readers  are going to the next posts in our blog [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/026.png" alt="HTML Minify" title="HTML Minify" width="550" height="226" class="alignnone size-full wp-image-404" /></p>
<p>Let&#8217;s review today such a contradictory point in website acceleration as HTML minify. It&#8217;s one of our steps to bring <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/">extreme performance to our website</a>. And it can reduce load time not only for the first-time visitors, but also for returned ones and if readers  are going to the next posts in our blog &#8211; for second pages and so on.</p>
<h3>HTML minify challenges</h3>
<p>Well. It seems be very simple &#8211; just remove all unnecessary symbols from HTML code. But what symbols are excessive? First of all &#8211; all line breaks and double spaces. But should we remove really all of them? The correct answer is &#8211; no. We can&#8217;t remove for sure any symbols from tags <code>pre</code>, <code>textarea</code>, and <code>script</code> to reduce overall HTML code size.</p>
<p>OK. We can leave these tags as they are. What else? Also we can&#8217;t touch aggressively line breaks inside inline elements (or between them) &#8211; because they are equivalent to spaces (per contra we can safely remove all space-like characters between block elements without any actual losses).Well&#8230; The hour is not easier.</p>
<p>Also we can remove HTML comments if they are not served to IE browsers (because latter can parse conditional comments). Or we should remove all comments exclude conditional.</p>
<h3>Practical solution</h3>
<p>There are a lot of reefs and too little possible gain. You can apply all HTML minify actions by hand (through your template code and blog posts). But this isn&#8217;t worth expected speedup.</p>
<p>You can also try to implement some (semi) automated solutions. But please don&#8217;t use <a href="http://wordpress.org/extend/plugins/w3-total-cache/" rel="nofollow">W3 Total Cache plugin</a> for aggressive HTML minify &#8211; it can break your layout. <a href="http://wordpress.org/extend/plugins/web-optimizer/">WEBO Site SpeedUp</a> which is being used for this website has complete support for all actions to minify data size including HTML documents.</p>
<p>Let&#8217;s try to enable HTML minify, Remove HTML comments (conditional comments are removed for non-IE browsers only), and &#8216;HTML-to-1-string&#8217; options. Here is final YSlow chart.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/026-2.png" alt="YSlow chart" title="YSlow chart" width="448" height="269" class="alignnone size-full wp-image-405" /></p>
<p>In comparison with the <a href="http://www.speedingupwebsite.com/2010/02/01/remove-unused-styles-make-your-website-lighter/">last performance situation</a> we have <strong>eliminated 0.6 Kb</strong> (remember &#8211; we are already using gzip compression), which is about 11% from HTML document and about 0.15% from page load speed. But it&#8217;s valid only for new visitors.</p>
<p>For returned visitors (is they have all the other resources cached &#8211; CSS, JavaScript, images) we have here 10% additional speedup. Except HTML document we have only small Google Analytics GIF-counter, which loads rather quickly. But in case of loading all assets from cache we face with rendering expenses. And actual speedup here will be less (we will try to count it in the future with rendering measurement).</p>
<h3>Conclusion</h3>
<p>HTML minify isn&#8217;t worth to be implemented for a common website. It does too little and can be very CPU (or time) expensive. If you are already using some strong caching solution &#8211; it&#8217;s better to include HTML minify to it. In all the other cases you can leave this <a href="http://www.speedingupwebsite.com/2010/01/08/the-right-way-to-speed-up-your-blog/">WordPress performance optimization</a> practice for geeks only.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>January 19, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/19/too-many-styles-shrink-them/" title="Too many styles? Shrink them!">Too many styles? Shrink them!</a> (1)</li><li>January 17, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/17/less-files-faster-website-but-how-much/" title="Less files &#8211; faster website, but how much?">Less files &#8211; faster website, but how much?</a> (2)</li><li>February 26, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/26/all-about-wordpress-performance-11-golden-rules/" title="All about WordPress performance &#8211; 11 golden rules">All about WordPress performance &#8211; 11 golden rules</a> (1)</li><li>January 29, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/" title="Reviewing speedup &#8211; from advanced to extreme website acceleration">Reviewing speedup &#8211; from advanced to extreme website acceleration</a> (0)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Q4vmUUR8B1o:J215iTOxxGs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Q4vmUUR8B1o:J215iTOxxGs:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=Q4vmUUR8B1o:J215iTOxxGs:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Q4vmUUR8B1o:J215iTOxxGs:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Q4vmUUR8B1o:J215iTOxxGs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=Q4vmUUR8B1o:J215iTOxxGs:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Q4vmUUR8B1o:J215iTOxxGs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=Q4vmUUR8B1o:J215iTOxxGs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Q4vmUUR8B1o:J215iTOxxGs:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=Q4vmUUR8B1o:J215iTOxxGs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=Q4vmUUR8B1o:J215iTOxxGs:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/Q4vmUUR8B1o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/02/02/html-minify-to-be-or-not-to-be/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/02/02/html-minify-to-be-or-not-to-be/</feedburner:origLink></item>
		<item>
		<title>Remove unused styles, make your website lighter</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/7id-mXShHOk/</link>
		<comments>http://www.speedingupwebsite.com/2010/02/01/remove-unused-styles-make-your-website-lighter/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 10:58:00 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[background images]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[data:URI]]></category>
		<category><![CDATA[unused CSS]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=387</guid>
		<description><![CDATA[
In the previous post we set plan to bring our website to the extreme performance level up. First of all we need somehow cut our styles (mostly to reduce amount of data:URI). Usually this operation doesn&#8217;t bring much web performance, but not in the case of base64-encoded images in CSS files.
What to start with?
We can [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=7.0" /></div><div>Rating: 7.0/<strong>10</strong> (1 vote cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/025.png" alt="Remove unused styles" title="Remove unused styles" width="550" height="226" class="alignnone size-full wp-image-388" /></p>
<p>In the previous post we set plan to <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/">bring our website to the extreme performance level</a> up. First of all we need somehow cut our styles (mostly to reduce amount of data:URI). Usually this operation doesn&#8217;t bring much <a href="/">web performance</a>, but not in the case of base64-encoded images in CSS files.</p>
<h3>What to start with?</h3>
<p>We can use either <a href="http://code.google.com/intl/ru/speed/page-speed/download.html" rel="nofollow">Page Speed</a> plugin for Firebug/Firefox, or <a href="https://addons.mozilla.org/ru/firefox/addon/5392" rel="nofollow">Dust-me Selectors</a> directly for Firefox to find CSS selectors which must be removed.</p>
<p>Our main criteria for now will be YSlow statistics chart &#8211; and size of the CSS files.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/025-1.png" alt="YSlow chart (before)" title="YSlow chart (before)" width="431" height="256" class="alignnone size-full wp-image-389" /></p>
<p>In our case all is very simple &#8211; we need to <a href="http://www.speedingupwebsite.com/2010/01/17/less-files-faster-website-but-how-much/">clean up GD Star Rating styles</a> from unused stars / thumbs. OK, going to GD Star Rating plugin settings and remember what sets do we have enabled there. In our case all stars are under &#8216;Soft&#8217; set. Also you need to remember which star sizes are actually used (in our case it&#8217;s 24 &#8211; for big ones &#8211; and 16 &#8211; for small ones). Also we don&#8217;t use thumbs in ratings.</p>
<h3>Fixing GD Star Rating</h3>
<p>After we have remembered all options let&#8217;s go to <code>wp-content/plugins/gd-star-rating/css/gdsr.css.php</code>. It seems that author tried to remove unused styles from dynamic styles generation. But without any actual success &#8211; generated CSS file link includes all possible sets and all possible sizes. We need to fix this situation.</p>
<p>So in file <code>wp-content/plugins/gd-star-rating/css/gdsr.css.php</code> find <code>$type == "s"</code> (near line 88) and replace this piece of code</p>
<blockquote><pre>if ($type == "s") {
	$folders[] = substr($r, 3);
	$sets[] = $set;
</pre>
</blockquote>
<p>with this one</p>
<blockquote><pre>if ($type == "s") {
	<strong>if ($set['folder'] == 'soft') {</strong>
		$folders[] = substr($r, 3);
		$sets[] = $set;
	}</pre>
</blockquote>
<p>Here we added our stars&#8217; set (&#8217;soft&#8217;) and restrict adding to the final array any other sets. If you use different set &#8211; use its name here.</p>
<p>Then a bit lower we need to cut all other arrays from unused values. So just before the line with</p>
<blockquote><pre>echo "/* stars sizes: ".join(", ", $sizes) ." */\r\n";</pre>
</blockquote>
<p>add the following</p>
<blockquote><pre>$sizes = array(16, 24);
$thumb_sizes = array();
$thumb_sets = array();</pre>
</blockquote>
<p>Here we cleaned up arrays with thumbs and restricted array with sizes to our actually used ones (16 and 24).</p>
<p>And the final change (actually to reduce amount of different data:URI chunks, not to reduce amount of CSS rules) is near line 154-159. Find there</p>
<blockquote><pre>foreach ($sets as $set) {</pre>
</blockquote>
<p>And replace this piece of code</p>
<blockquote><pre>
echo $class." .starsbar.gdsr-size-".$size." .gdouter { background: url(...";
echo $class." .starsbar.gdsr-size-".$size." .gdinner { background: url(...";
echo $class." .starsbar.gdsr-size-".$size." .gdcurrent { background: url(...";
echo $class." .starsbar.gdsr-size-".$size." a:hover { background: url(...";</pre>
</blockquote>
<p>with this one</p>
<blockquote><pre>echo $class." .starsbar.gdsr-size-".$size." .gdouter{background:repeat-x 0 0}\r\n";
echo $class." .starsbar.gdsr-size-".$size." .gdinner{background:repeat-x 0 -".(2 * $size)."px}\r\n";
echo $class." .starsbar.gdsr-size-".$size." .gdcurrent{background:repeat-x 0 -".($size)."px}\r\n";
echo $class." .starsbar.gdsr-size-".$size." a:hover{background:repeat-x 0 -".$size."px!important}\r\n";
echo $class." .starsbar.gdsr-size-".$size." .gdouter,\r\n".
  $class." .starsbar.gdsr-size-".$size." .gdinner,\r\n".
  $class." .starsbar.gdsr-size-".$size." .gdcurrent,\r\n".
  $class." .starsbar.gdsr-size-".$size." a:hover{background-image:url('".$url."')!important}\r\n";</pre>
</blockquote>
<h3>Results</h3>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/02/025-2.png" alt="YSlow statistics (after)" title="YSlow statistics (after)" width="463" height="259" class="alignnone size-full wp-image-396" /></p>
<p>Here we have saved 75 Kb of data (and now can merge our CSS files back) &#8211; most of this amount was related to data:URI in unused CSS. But during styles cleaning we have found missed background image (blue splash), which must be somehow minified. After converting from JPEG to PNG we have saved additionally 30 Kb but it&#8217;s still too large. Need to think how the situation can be improved here.</p>
<p>We have not finished yet with unused selectors &#8211; but with large chunks of unused data maybe. In one of the next posts we will completely review how you can determine and remove really unused CSS rules (because 1 CSS file can be applied for different website pages, and each page doesn&#8217;t have all DOM elements which are described in CSS).</p>
<h3>Conclusion</h3>
<p>Removing unused styles can help you to speed up your website, sometimes even significantly. In our case simple actions have saved <strong>75 Kb of data, or about 20%</strong>. Also this should increase page rendering speed but not so notably (we will check later how it increases in this case &#8211; but it&#8217;s about 10 ms gain).</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=7.0" /></div><div>Rating: 7.0/<strong>10</strong> (1 vote cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>January 29, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/" title="Reviewing speedup &#8211; from advanced to extreme website acceleration">Reviewing speedup &#8211; from advanced to extreme website acceleration</a> (0)</li><li>January 21, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/21/add-more-caching-wit-background-images/" title="Add more caching with (background) images">Add more caching with (background) images</a> (0)</li><li>January 20, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/20/datauri-is-the-next-generation-of-acceleration/" title="data:URI is the next generation of acceleration techniques">data:URI is the next generation of acceleration techniques</a> (2)</li><li>March 7, 2010 -- <a href="http://www.speedingupwebsite.com/2010/03/07/dynamic-css-javascript-are-evil-8-reasons/" title="Dynamic CSS / JavaScript files are evil &#8211; 8 reasons">Dynamic CSS / JavaScript files are evil &#8211; 8 reasons</a> (4)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=7id-mXShHOk:IJ4VKDZQ-lM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=7id-mXShHOk:IJ4VKDZQ-lM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=7id-mXShHOk:IJ4VKDZQ-lM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=7id-mXShHOk:IJ4VKDZQ-lM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=7id-mXShHOk:IJ4VKDZQ-lM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=7id-mXShHOk:IJ4VKDZQ-lM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=7id-mXShHOk:IJ4VKDZQ-lM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=7id-mXShHOk:IJ4VKDZQ-lM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=7id-mXShHOk:IJ4VKDZQ-lM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=7id-mXShHOk:IJ4VKDZQ-lM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=7id-mXShHOk:IJ4VKDZQ-lM:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/7id-mXShHOk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/02/01/remove-unused-styles-make-your-website-lighter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/02/01/remove-unused-styles-make-your-website-lighter/</feedburner:origLink></item>
		<item>
		<title>Reviewing speedup – from advanced to extreme website acceleration</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/NMrcZJQXeWk/</link>
		<comments>http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 23:58:11 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[Performance Measurement]]></category>
		<category><![CDATA[Server Side Performance]]></category>
		<category><![CDATA[background images]]></category>
		<category><![CDATA[CSS images]]></category>
		<category><![CDATA[CSS Spiites]]></category>
		<category><![CDATA[data:URI]]></category>
		<category><![CDATA[mhtml]]></category>
		<category><![CDATA[minify]]></category>
		<category><![CDATA[multiple hosts]]></category>
		<category><![CDATA[webo site speedup]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=373</guid>
		<description><![CDATA[
Yesterday we completely finished with our performance optimization Stage 2 (advanced techniques). Let&#8217;s review how much acceleration we have got during this process.
Actual progress
As you can remember we have website load time about 4.2 seconds (clean cache) and the following YSlow chart.

Now we have a bit better situation (with load time about 3.8 seconds).

Minus 29 [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=9.0" /></div><div>Rating: 9.0/<strong>10</strong> (1 vote cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/0241.png" alt="Reviewing speedup - advanced techniques" title="Reviewing speedup - advanced techniques" width="550" height="226" class="alignnone size-full wp-image-374" /></p>
<p>Yesterday we completely finished with our <a href="http://www.speedingupwebsite.com/2010/01/16/reviewing-speedup-from-basics-to-advanced-techniques/">performance optimization Stage 2</a> (advanced techniques). Let&#8217;s review how much acceleration we have got during this process.</p>
<h3>Actual progress</h3>
<p>As you can remember we have website load time about 4.2 seconds (clean cache) and the following YSlow chart.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/013-2.png" alt="YSlow statistics" title="YSlow statistics" width="461" height="269" class="alignnone size-full wp-image-212" /></p>
<p>Now we have a bit better situation (with load time about 3.8 seconds).</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/024-1.png" alt="YSlow chart - after" title="YSlow chart - after" width="469" height="273" class="alignnone size-full wp-image-375" /></p>
<p>Minus 29 <a href="http://www.speedingupwebsite.com/2010/02/05/fighting-http-requests-combine-images/">HTTP requests</a>, minus 25 Kb in size (but please note that we have now 1 banner &#8211; about <a href="http://www.web-optimizer.us/ru/?utm_source=speedingupwebsite.com&#038;utm_medium=internal&#038;utm_campaign=speedingupwebsite.com.banner">WEBO Site SpeedUp</a>, which is about 10 Kb). So we have achieved <strong>about 10% more speedup</strong> for new visitors (and about nothing for returned visitors). It seems there is something wrong (we planned to get <a href="http://www.speedingupwebsite.com/2010/01/16/reviewing-speedup-from-basics-to-advanced-techniques/">20-30% over Stage 1 speedup</a>).</p>
<p>All applied actions, one-by-one:</p>
<ul>
<li><a href="http://www.speedingupwebsite.com/2010/01/17/less-files-faster-website-but-how-much/">Merged, compressed, and delayed JavaScript files</a>. About 6% of speedup.</li>
<li><a href="http://www.speedingupwebsite.com/2010/01/19/too-many-styles-shrink-them/">Merged and compressed CSS files</a>. About 5% of speedup.</li>
<li><a href="http://www.speedingupwebsite.com/2010/01/20/datauri-is-the-next-generation-of-acceleration/">Applied data:URI, mhtml</a>, and <a href="http://www.speedingupwebsite.com/2010/01/20/even-faster-styles-with-data-uri/">delayed data:URI</a>. About 17% of speedup.</li>
<li><a href="http://www.speedingupwebsite.com/2010/01/21/add-more-caching-wit-background-images/">Used aggressive background images</a>. 4% more speedup.</li>
<li><a href="http://www.speedingupwebsite.com/2010/01/23/css-sprites-revealing-sealed-myster/">Used CSS Sprites</a>. No actual speedup over dataLURI (just more dynamic interface maybe).</li>
<li><a href="http://www.speedingupwebsite.com/2010/01/26/statify-dynamic-images-from-timthumb/">Replaced dynamic images with static ones</a>. Less than 1% speedup.</li>
<li><a href="http://www.speedingupwebsite.com/2010/01/27/parallelize-images-multiple-domains-in-action/">Used multiple domains</a>. About 5% more speedup.</li>
</ul>
<p>A simple sum from these actions gives us 38%, but we have got only 10%. What&#8217;s wrong?</p>
<p>Also we have approval picture from Google Webmasters that almost nothing was changed with our WordPress website load speed.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/024-2.png" alt="Google Webmasters speedup" title="Google Webmasters speedup" width="679" height="143" class="alignnone size-full wp-image-378" /></p>
<h3>Analyzing drawbacks</h3>
<p>Actually a lot of information goes from understanding what actions were applied and what each of them brought to our website. The worst thing here is&#8230; data:URI. This technique includes into our CSS file (the second one, with all background images) a lot of excessive base64-encoded data. This was happen due to not properly tuned data:URI usage and bad GD Star Rating plugin behavior (instead of including only required styles to the final CSS file this plugin includes all possible what makes this file much bigger).</p>
<p>But let&#8217;s take a look to Page Speed analysis (it&#8217;s under Firefox 3.5.7, since 3.6 doesn&#8217;t support this plugin yet).</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/024-3.png" alt="Page Speed analysis" title="Page Speed analysis" width="378" height="287" class="alignnone size-full wp-image-379" /></p>
<p>Almost all of yellow (medium warnings) points can give us a little speedup. But &#8216;Remove unused CSS&#8217; seems to cut our resource CSS file by about 50% (26 Kb). It seems it&#8217;s the point &#8211; our lost 28% of speedup.</p>
<h3>Planning new actions</h3>
<p>We are going to improve our website load speed step by step, analyzing and evaluating all possibilities. For now we have tried a lot of different methods and see actual result. Let&#8217;s prepare new list of actions with possible acceleration.</p>
<ol>
<li><a href="http://www.speedingupwebsite.com/2010/02/01/remove-unused-styles-make-your-website-lighter/">Remove unused CSS</a>. We will get here (due to data:URI usage) about 15% of speedup.</li>
<li>Server static content from 3rd-party domains (we <a href="http://www.speedingupwebsite.com/2010/01/27/parallelize-images-multiple-domains-in-action/">mentioned 2static.it service</a>, maybe it can help?). About nothing here (less than 1% of speedup).</li>
<li>Try to combine HTML images on the home page (i.e. just thumbnails) + or move some of them to CSS background. We will save here also about nothing, less than 1%.</li>
<li>Page Speed also talks about dimensions for our images on the home page. Most of these issues will be fixed with the previous point, but we should somehow measure actual speedup here &#8211; we will review how to measure page rendering in browsers.</li>
<li>Also we should try to apply <a href="http://www.speedingupwebsite.com/2010/02/02/html-minify-to-be-or-not-to-be/">HTML minify</a> with already gzipped HTML documents. Maybe this will save about 1-2% of load speed.</li>
<li>&#8230;And? Yes, maybe &#8216;Efficient CSS selectors&#8217;. But probably we will leave them for Stage 4. And we will try to add 2-3 Google AdSense blocks to the website and see how they influence our website load speed. And how can they be made unobtrusive (non-blocking, delayed).</li>
</ol>
<p>OK. It seems we have a great plan for the next week <img src='http://www.speedingupwebsite.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Conclusion</h3>
<p>Advanced website performance actions can give about 30-50% (after 300% speedup from basic ones), but it will take more time and require more knowledge to use all techniques (i.e. data:URI) properly. And even after all these techniques have been applied you still have some stuff to improve. And we will review it in the next blog posts.</p>
<p>We are going to make our website extreme fast. Are you ready? Fasten your seat belts!</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=9.0" /></div><div>Rating: 9.0/<strong>10</strong> (1 vote cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>January 21, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/21/add-more-caching-wit-background-images/" title="Add more caching with (background) images">Add more caching with (background) images</a> (0)</li><li>January 20, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/20/datauri-is-the-next-generation-of-acceleration/" title="data:URI is the next generation of acceleration techniques">data:URI is the next generation of acceleration techniques</a> (2)</li><li>February 26, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/26/all-about-wordpress-performance-11-golden-rules/" title="All about WordPress performance &#8211; 11 golden rules">All about WordPress performance &#8211; 11 golden rules</a> (1)</li><li>February 21, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/21/html-sprites-new-weapon-against-http-requests/" title="HTML Sprites &#8211; new weapon against HTTP requests">HTML Sprites &#8211; new weapon against HTTP requests</a> (2)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=NMrcZJQXeWk:f7QsvxdYsZw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=NMrcZJQXeWk:f7QsvxdYsZw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=NMrcZJQXeWk:f7QsvxdYsZw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=NMrcZJQXeWk:f7QsvxdYsZw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=NMrcZJQXeWk:f7QsvxdYsZw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=NMrcZJQXeWk:f7QsvxdYsZw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=NMrcZJQXeWk:f7QsvxdYsZw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=NMrcZJQXeWk:f7QsvxdYsZw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=NMrcZJQXeWk:f7QsvxdYsZw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=NMrcZJQXeWk:f7QsvxdYsZw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=NMrcZJQXeWk:f7QsvxdYsZw:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/NMrcZJQXeWk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/</feedburner:origLink></item>
		<item>
		<title>Using CDN – is it cool?</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/8AJJtiH_X_o/</link>
		<comments>http://www.speedingupwebsite.com/2010/01/28/using-cdn-isit-cool/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 23:15:21 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[Performance Measurement]]></category>
		<category><![CDATA[CDN]]></category>
		<category><![CDATA[w3 total cache]]></category>
		<category><![CDATA[webo site speedup]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=363</guid>
		<description><![CDATA[
We reviewed multiple hosts application to our website and get a little more speedup. So let&#8217;s see how CDN (Content Delivery Network) can help us.
Actually CDN is a large number of servers which are distributed all over the world and have very good connection timings (so every HTTP request costs about 1-2ms). This will greatly [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/023.png" alt="Using CDN" title="Using CDN" width="550" height="226" class="alignnone size-full wp-image-364" /></p>
<p>We reviewed <a href="http://www.speedingupwebsite.com/2010/01/27/parallelize-images-multiple-domains-in-action/">multiple hosts application</a> to our website and get a little more speedup. So let&#8217;s see how CDN (Content Delivery Network) can help us.</p>
<p>Actually CDN is a large number of servers which are distributed all over the world and have very good connection timings (so every HTTP request costs about 1-2ms). This will greatly help if your website has a lot of small objects (CSS or JavaScript files, background images, etc). But what if we have about 20 objects per page with an average size of 20 Kb?</p>
<h3>Measuring performance</h3>
<p>Here we have HTTP waterfall picture for our website (it&#8217;s YSlow, but you can get with any of <a href="http://www.speedingupwebsite.com/2010/01/07/is-my-wordpress-blog-fast-enough-part-2/">client side performance measurement tools</a>).</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/023-1.png" alt="YSlow waterfall" title="YSlow waterfall" width="596" height="403" class="alignnone size-full wp-image-365" /></p>
<p>Well, here we have 8 chunks of data loading &#8211; HTML document, 1st CSS file, 2nd CSS file, 2 chunks of images, then Google Analytics library, then CSS Sprites, then Google Analytics counter (transparent 1-pixel GIF file). But to show page on a screen (blue line here) we require we really have 5 chunks of data (Google Analytics library seems to use it&#8217;s own DNS, so it&#8217;s better to keep in unchanged).</p>
<p>If we are going to cache HTML document (which can be potentially dangerous) &#8211; we can influence here (on a well-accelerated website) only on 5 consequent steps of <a href="http://www.speedingupwebsite.com/2010/02/05/fighting-http-requests-combine-images/">HTTP requests</a> (so if we eliminate all server side delays and our HTTP requests will return at once &#8211; we will save here only 5*gain due to concurrent requests to images).</p>
<p>We <a href="http://www.speedingupwebsite.com/2010/01/26/statify-dynamic-images-from-timthumb/">measured actual server delays</a> a few days ago so we can say for sure that overall load time will increase by</p>
<blockquote><pre>5 chunks * (15 - 1) ms = 70 ms</pre>
</blockquote>
<p>Total web page load speed won&#8217;t be influenced much with CDN usage. It&#8217;s like any other <a href="http://www.speedingupwebsite.com/2010/01/16/reviewing-speedup-from-basics-to-advanced-techniques/">methods in Stage 2</a> &#8211; only 3-5%.</p>
<p><strong>Please note:</strong> these calculations are valid only if you have applied all <a href="http://www.speedingupwebsite.com/2010/01/08/the-right-way-to-speed-up-your-blog/">first priority client side optimization actions</a> (including <a href="http://www.speedingupwebsite.com/2010/01/13/5x-speedup-with-client-side-caching/">client side caching</a>). If you have huge time to generate your HTML document, dozens of JavaScript or CSS files, a lot of background images &#8211; CDN will be a &#8217;silver bullet&#8217; for your website. But actual speedup can be achieved even without it.</p>
<p>Moreover CDN usage can be replaced with <a href="http://www.speedingupwebsite.com/2010/01/27/parallelize-images-multiple-domains-in-action/">multiple hosts</a> (actually it&#8217;s not the truth, but in the first approach it&#8217;s right) &#8211; you can reduce Cookie size sending to get <a href="http://www.speedingupwebsite.com/2010/01/26/statify-dynamic-images-from-timthumb/">static resources</a> and reduce efficient delay to get any of your resources (usually &#8211; static images).</p>
<h3>WordPress plugins</h3>
<p>If you are using CDN there are some WordPress plugins which can help you to replace URL for your static assets with CDN-equivalents.</p>
<p>The first is <a href="http://wordpress.org/extend/plugins/w3-total-cache/" rel="nofollow">W3 Total Cache</a>. It has quite a lot of options to enable CDN support.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/023-2.png" alt="W3 Total Cache options" title="W3 Total Cache options" width="677" height="723" class="alignnone size-full wp-image-367" /></p>
<p>Not sure if all of them are very useful but with enabling CDN support some of the resources were distributed to <code>i1</code> and some were not. Maybe it uses 2 hosts by default for distribution (www and defined one).</p>
<p>The second one &#8211; <a href="http://wordpress.org/extend/plugins/web-optimizer/" rel="nofollow">WEBO Site SpeedUp</a> &#8211; has less options but still can be used to automate CDN distribution (<a href="http://blog.web-optimizer.us/2009/12/web-optimizer-for-cdn.html">according to this blog post</a>). You can just setup only 1 host in Multiple hosts group of options.</p>
<p><img src="http://i2.speedingupwebsite.com/wp-content/uploads/2010/01/022-2.png" alt="WEBO Site SpeedUp multiple hosts" title="WEBO Site SpeedUp multiple hosts" width="332" height="350" class="alignnone size-full wp-image-354" /></p>
<p>And get all images re-linked to CDN. Also you can re-define default website host in System Status.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/023-3.png" alt="System Status website host" title="System Status website host" width="245" height="112" class="alignnone size-full wp-image-368" /></p>
<p>This will turn on distribution for merged CSS and JavaScript files (if it&#8217;s required).</p>
<h3>Conclusion</h3>
<p>For well accelerated website CDN can be useful only as a caching level. Actual speedup will be about 100 ms what is less than after simple CSS files merging. But if you are looking to bring extreme performance for your website you should consider CDN usage. Also there are a number of WordPress plugins to automate CDN integration into WordPress website.</p>
<p>Here we are finishing with Stage 2 (advanced <a href="http://www.webogroup.com/solutions/">web performance optimization</a>) for our website. We will review savings and schedule next stage 3 &#8211; really high performance &#8211; with the help of cutting edge technologies and tools.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>January 19, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/19/too-many-styles-shrink-them/" title="Too many styles? Shrink them!">Too many styles? Shrink them!</a> (1)</li><li>January 17, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/17/less-files-faster-website-but-how-much/" title="Less files &#8211; faster website, but how much?">Less files &#8211; faster website, but how much?</a> (2)</li><li>January 15, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/15/40x-speedup-with-server-side-caching-which-one-is-the-best/" title="40x speedup with server side caching, which one is the best?">40x speedup with server side caching, which one is the best?</a> (0)</li><li>March 7, 2010 -- <a href="http://www.speedingupwebsite.com/2010/03/07/dynamic-css-javascript-are-evil-8-reasons/" title="Dynamic CSS / JavaScript files are evil &#8211; 8 reasons">Dynamic CSS / JavaScript files are evil &#8211; 8 reasons</a> (4)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=8AJJtiH_X_o:0DxVkw4s1fE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=8AJJtiH_X_o:0DxVkw4s1fE:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=8AJJtiH_X_o:0DxVkw4s1fE:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=8AJJtiH_X_o:0DxVkw4s1fE:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=8AJJtiH_X_o:0DxVkw4s1fE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=8AJJtiH_X_o:0DxVkw4s1fE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=8AJJtiH_X_o:0DxVkw4s1fE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=8AJJtiH_X_o:0DxVkw4s1fE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=8AJJtiH_X_o:0DxVkw4s1fE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=8AJJtiH_X_o:0DxVkw4s1fE:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=8AJJtiH_X_o:0DxVkw4s1fE:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/8AJJtiH_X_o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/01/28/using-cdn-isit-cool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/01/28/using-cdn-isit-cool/</feedburner:origLink></item>
		<item>
		<title>Parallelize images – multiple domains in action</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/a7FkaXZ-Hws/</link>
		<comments>http://www.speedingupwebsite.com/2010/01/27/parallelize-images-multiple-domains-in-action/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 18:49:25 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[multiple hosts]]></category>
		<category><![CDATA[webo site speedup]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=351</guid>
		<description><![CDATA[
Yesterday we prepared our dynamic images to be distributed among the static ones. Let&#8217;s see how this can be implemented.
First of all what will we gain after images distribution? On the home page we have 19 images (and about 12 on every blog post one). Actually there are 17 images, 1 CSS image (yes, our [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/022.png" alt="Use multiple domains" title="Use multiple domains" width="550" height="226" class="alignnone size-full wp-image-352" /></p>
<p>Yesterday <a href="http://www.speedingupwebsite.com/2010/01/26/statify-dynamic-images-from-timthumb/">we prepared our dynamic images</a> to be distributed among the static ones. Let&#8217;s see how this can be implemented.</p>
<p>First of all what will we gain after images distribution? On the home page we have 19 images (and about 12 on every blog post one). Actually there are 17 images, 1 CSS image (yes, <a href="http://www.speedingupwebsite.com/2010/01/23/css-sprites-revealing-sealed-myster/">our prepared CSS Sprite</a>), and 1 favicon (which can&#8217;t be distributed efficiently &#8211; it will be requested from the main domain as well). As far as <a href="http://www.browserscope.org/" rel="nofollow">browsers use about in average 4 connections</a> per hostname, there will be about 4-5 chunks connections on load waterfall.</p>
<p>It looks like this waterfall.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/022-1.png" alt="Load waterfall for images" title="Load waterfall for images" width="485" height="318" class="alignnone size-full wp-image-353" /></p>
<p>Browser has to wait until connection is ready to be used. So this adds delay to the page load process.</p>
<h3>How to use multiple hosts</h3>
<p>The simplest way to eliminate these delays is to use multiple domains (because it&#8217;s &#8216;per host&#8217; limit) with the same pictures. And this speed website load up. You can check post about <a href="http://www.speedingupwebsite.com/2010/01/14/caching-everything-caching-everywhere/">caching various types of data</a>, there were reviewed possible ways to use some free <a href="http://www.speedingupwebsite.com/2010/01/28/using-cdn-isit-cool/">CDN-like resources</a> to provide caching for static assets. This also can be used to distribute images (you can for example place all of them to Picasa and use its own distribution logic).</p>
<p>But our post isn&#8217;t about using some external resources. We are going to implement some domestic solution (to integrate it into our blog once and use all the time).</p>
<h3>Preparing static mirrors</h3>
<p>To work efficiently with multiple hosts distribution you need to add some hosts to mirror your main one (of course you can us more complicated scheme &#8211; i.e. point new host to a specific directory on your web server &#8211; but this requires direct access to configuration file what can be impossible for shared hosting). First of all you need to add a few records to DNS (if you don&#8217;t know what is it &#8211; you can just try to use great service <a href="http://2static.it/" rel="nofollow">2static.it</a> which allows you to create such aliases via web interface for any host).</p>
<p>Note: to add proper records to DNS you need</p>
<ul>
<li>Either add A-type record, for example<br />
<blockquote><pre>i1 IN A X.X.X.X</pre>
</blockquote>
<p>Where <code>i1</code> is a desired host for your website mirror (<code>i1.speedingupwebsite.com</code>) and <code>X.X.X.X</code> is your website IP address (you can get it with simple <code>ping yourwebsite.com</code> in command line or with any of SEO check tools).</li>
<li>Or add CNAME-type record like<br />
<blockquote><pre>i1 IN CNAME yourwebsite.com</pre>
</blockquote>
</li>
</ul>
<p>If you have any troubles with static aliases setup your can write to your hosting provider support or check how this can be performed via hosting administrative panel (usually there are some tools).</p>
<p>OK. After we have chosen 2-4 domain names on 2static.it or have added aliases to DNS we need to check their availability and request some resources from them. For example images. So this request</p>
<blockquote><pre>http://i1.yourwebsite.com/wp-content/themes/basicpress/images/some.image.png</pre>
</blockquote>
<p>must show you exactly the same image as the following one</p>
<blockquote><pre>http://www.yourwebsite.com/wp-content/themes/basicpress/images/some.image.png</pre>
</blockquote>
<p>Here we have <code>i1</code> &#8211; your chosen host (one of the 2-4 prepared) &#8211; and <code>yourwebsite.com</code> &#8211; your website domain.</p>
<p>Well. We are ready to implement these static mirrors to our website templates.</p>
<h3>Handy solution</h3>
<p>Well, let&#8217;s try to implement some kind of solution &#8216;by hand&#8217;. First we should analyze current website structure and somehow distribute images in our mind. So all (6) images from the top slide show can be served from 1 host, and 10 thumbnails on the home page for posts can be server via 2 another domains. Also we can still have the main one &#8211; www.speedingupwebsite.com &#8211; as one more mirror (it&#8217;s not very good, because we will have cookies sent for it, but eliminates one more DNS request). So there are totally 3 more domains. Also we can leave pictures in posts themselves on the main domain &#8211; posts are large in height and images&#8217; load sped isn&#8217;t crucial here.</p>
<p><strong>A question:</strong> why shouldn&#8217;t we implement 10+ static hosts &#8211; to guarantee extreme website performance even for IE7- wit 2 requests per domain? Because every new web host requires DNS request. Which isn&#8217;t cached for a new visitor (but for returned visitors we already have <a href="http://www.speedingupwebsite.com/2010/01/13/5x-speedup-with-client-side-caching/">client side cache</a>). So we reduce delays but payload in the number of DNS requests. And Yahoo! showed that <a href="http://yuiblog.com/blog/2007/04/11/performance-research-part-4/" rel="nofollow">optimal number is about 2-4</a>.</p>
<p>OK. So we need to find where slide show images are called from. In our case it&#8217;s the file <code>wp-content/themes/basicpress/header.php</code>. Here we change all occurrences of</p>
<blockquote><pre>&lt;img src="&lt;?php bloginfo( 'template_directory' ); ?&gt;</pre>
</blockquote>
<p>to</p>
<blockquote><pre>&lt;img src="http://i1.yourwebsite.com/wp-content/themes/basicpress</pre>
</blockquote>
<p><strong>i1.yourwebsite.com</strong> is a mirror we have added a bit earlier. Here we had 4 such places to change.</p>
<p>OK. Let&#8217;s check our website &#8211; all top images are loaded from this mirror. That&#8217;s great.</p>
<p>The second fix (to distribute posts&#8217; images on the home page) will be in <code>wp-content/themes/basicpress/index.php</code>. Almost the same changes.</p>
<blockquote><pre>&lt;img src="&lt;?php bloginfo( 'template_directory' ); ?&gt;</pre>
</blockquote>
<p>to</p>
<blockquote><pre>&lt;img src="http://i&lt;?php echo ($post->ID % 2)+2 ?&gt;.yourwebsite.com/wp-content/themes/basicpress</pre>
</blockquote>
<p>In this example we try to set a permanent web host for each post image (because it&#8217;s not very good to change hosts for the same images in terms of content). So we connect host to post ID (and use 2 mirrors only &#8211; <code>i2</code> and <code>i3</code>).</p>
<p>Congratulations. We have distributed our images through multiple hosts.</p>
<h3>Automatic distribution</h3>
<p>Steps described above can be a bit complicated if you have not just a simple blog. Or have 20+ images on the home page. So here we can use some automated systems.</p>
<p>We will cover CDN and WordPress plugins to distribute images in details in the next post. But to end with image distribution for now we can just implement <a href="http://wordpress.org/extensions/plugins/web-optimizer/" rel="nofollow">WEBO Site SpeedUp</a> group of options.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/022-2.png" alt="WEBO Site SpeedUp multiple hosts" title="WEBO Site SpeedUp multiple hosts" width="332" height="350" class="alignnone size-full wp-image-354" /></p>
<p>Every image will be linked to its own host (it won&#8217;t be changed from page to page or update to update), and this will force all images on your website (not only on the home page, or only in slide show) to be mirrored. Very easy.</p>
<p>So after this implementation we have the following load diagram.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/022-3.png" alt="Firebug Net Panel - after" title="Firebug Net Panel - after" width="443" height="291" class="alignnone size-full wp-image-358" /></p>
<p>What looks much better in terms of client side performance.</p>
<h3>Conclusion</h3>
<p>Multiple hosts are not very easy to be implemented (because in every case your need to add some static mirrors for your website). And they don&#8217;t bring much performance in modern browsers &#8211; this technique works very well only in old IE. But in any case with it we can gain <strong>about additional 200ms, or 5%</strong> for our website load speed. This speedup isn&#8217;t critical (it doesn&#8217;t affect time of the first page appearance in visitor&#8217;s browser) but helps to bring extreme performance for our website.</p>
<p>This is almost the last part of our <a href="http://www.speedingupwebsite.com/2010/01/16/reviewing-speedup-from-basics-to-advanced-techniques/">Stage 2 of the performance optimization process</a>. We are going to finish it with a complete review this week.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>February 3, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/03/are-cookie-free-domains-eficien/" title="Are cookie-free domains efficient?">Are cookie-free domains efficient?</a> (1)</li><li>January 29, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/" title="Reviewing speedup &#8211; from advanced to extreme website acceleration">Reviewing speedup &#8211; from advanced to extreme website acceleration</a> (0)</li><li>March 7, 2010 -- <a href="http://www.speedingupwebsite.com/2010/03/07/dynamic-css-javascript-are-evil-8-reasons/" title="Dynamic CSS / JavaScript files are evil &#8211; 8 reasons">Dynamic CSS / JavaScript files are evil &#8211; 8 reasons</a> (4)</li><li>February 26, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/26/all-about-wordpress-performance-11-golden-rules/" title="All about WordPress performance &#8211; 11 golden rules">All about WordPress performance &#8211; 11 golden rules</a> (1)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=a7FkaXZ-Hws:QwKvcgYqveU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=a7FkaXZ-Hws:QwKvcgYqveU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=a7FkaXZ-Hws:QwKvcgYqveU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=a7FkaXZ-Hws:QwKvcgYqveU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=a7FkaXZ-Hws:QwKvcgYqveU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=a7FkaXZ-Hws:QwKvcgYqveU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=a7FkaXZ-Hws:QwKvcgYqveU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=a7FkaXZ-Hws:QwKvcgYqveU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=a7FkaXZ-Hws:QwKvcgYqveU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=a7FkaXZ-Hws:QwKvcgYqveU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=a7FkaXZ-Hws:QwKvcgYqveU:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/a7FkaXZ-Hws" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/01/27/parallelize-images-multiple-domains-in-action/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/01/27/parallelize-images-multiple-domains-in-action/</feedburner:origLink></item>
		<item>
		<title>Statify dynamic images from timthumb</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/q2CaksLOtKQ/</link>
		<comments>http://www.speedingupwebsite.com/2010/01/26/statify-dynamic-images-from-timthumb/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 20:40:56 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Performance Measurement]]></category>
		<category><![CDATA[Server Side Performance]]></category>
		<category><![CDATA[image optimization]]></category>
		<category><![CDATA[measurement]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[webo.name]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=338</guid>
		<description><![CDATA[
Just to remind: we are going through WordPress performance optimization stage 2 (after 3x speed from Stage 1) and focusing on decrease of number (or payload) of HTTP requests. Last several posts were devoted to CSS images optimization. We reduced their number and reviewed some well-known techniques to perform this automatically (or semi-automatically).
Before we start [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=10.0" /></div><div>Rating: 10.0/<strong>10</strong> (2 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/021.png" alt="Make images static" title="Make images static" width="550" height="226" class="alignnone size-full wp-image-339" /></p>
<p>Just to remind: we are going through <a href="http://www.speedingupwebsite.com/2010/01/08/the-right-way-to-speed-up-your-blog/">WordPress performance optimization</a> stage 2 (after 3x speed from Stage 1) and focusing on decrease of number (or payload) of HTTP requests. <a href="http://www.speedingupwebsite.com/2010/01/20/datauri-is-the-next-generation-of-acceleration/">Last</a> <a href="http://www.speedingupwebsite.com/2010/01/20/even-faster-styles-with-data-uri/">several posts</a> <a href="http://www.speedingupwebsite.com/2010/01/21/add-more-caching-wit-background-images/">were devoted to</a> <a href="http://www.speedingupwebsite.com/2010/01/23/css-sprites-revealing-sealed-myster/">CSS images</a> <a href="http://www.speedingupwebsite.com/2010/01/24/creating-css-sprites-drawbacks-and-challenges/">optimization</a>. We reduced their number and reviewed some well-known techniques to perform this automatically (or semi-automatically).</p>
<p>Before we start with actual HTML images distribution through multiple hosts (yes, it&#8217;s the most powerful technique here) we need to prepare our thumbnail library &#8211; timthumb &#8211; to be more fast and reliable.</p>
<h3>Why dynamic images are evil?</h3>
<p>Frankly speaking it&#8217;s very convenient &#8211; to upload only one image to the website and create thumbnails of any size from it. But let&#8217;s reveal this anti-pattern of <a href="http://www.webogroup.com/solutions/">web performance optimization</a>. For this image (from the last post)</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/020.png" alt="CSS Sprites challenges" title="CSS Sprites challenges" width="550" height="226"/></p>
<p>We have the following timings (get by <a href="http://webo.name/my/action/timings/" rel="nofollow">webo.name</a>).</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/021-1.png" alt="Timings for static image" title="Timings for static image" width="613" height="197" class="alignnone size-full wp-image-340" /></p>
<p>Here we have about 12ms &#8211; it&#8217;s too much (but we remember &#8211; we are working on a weak shared hosting, it&#8217;s a miracle that website can load so fast here) for server side expenses. And for a dynamic equivalent for this static image we have the following figure.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/021-2.png" alt="Dynamic image timings" title="Dynamic image timings" width="710" height="217" class="alignnone size-full wp-image-341" /></p>
<p>It&#8217;s about 8ms difference. It&#8217;s not so much, isn&#8217;t it? Really? <img src='http://www.speedingupwebsite.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  For the home page we have 3 large dynamic images (slide show) and 3 smaller (for the slide show too). <code>16 images x 8ms = 128ms</code>. It&#8217;s still not so much but if we compare these expenses with our <a href="http://www.speedingupwebsite.com/2010/01/15/40x-speedup-with-server-side-caching-which-one-is-the-best/">home page (and every HTML cached page) timings</a> we can see that dynamic image generation &#8216;eats&#8217; <strong>more than 6x</strong> from just HTML document response time.</p>
<p>And with every hit to the home page we lose 130ms (and can&#8217;t serve 5x more hits with our shared hosting). Please note &#8211; this is about home page, pagination and archives pages (with a lot of thumbnails) only. On single post pages there are only 6 such images &#8211; mush less but still 2x losses.</p>
<h3>How to fix this?</h3>
<p>Well the idea is clear enough. We need to create mnemonic file names for each dynamic image (as you remember we actually <a href="http://www.speedingupwebsite.com/2010/01/12/amazing-speed-up-with-image-optimization/">enabled their caching on Stage 1</a>). And then just add little rewrite magic to <code>.htaccess</code> (sorry if you are not using Apache, maybe you can create the same rules for nginx, lighttpd, or something else) to check cached thumbnail existence and serve it instead of calling dynamic script.</p>
<h3>Starting with timthumb.php</h3>
<p>We are going to <code>wp-content/themes/bacipress/</code> (it&#8217;s our <code>timthumb.php</code> actual location &#8211; it seems to be in the curent theme folder). Cache files are named like md5 hash. So let&#8217;s look for a function <code>md5</code> whch can perform such transformation.</p>
<p>On the line 338 there is</p>
<blockquote><pre>$cache_file = md5( $cachename ) . '.' . $ext;</pre>
</blockquote>
<p>It seems it&#8217;s what we are looking for.<br />
File name is calculated in these 2 lines (this one and the one above).</p>
<blockquote><pre>$cachename = get_request( 'src', 'timthumb' ) ...
$cache_file = md5( $cachename ) . '.' . $ext;</pre>
</blockquote>
<p>So we need to change logic of <code>$cachename</code> creation. And remove md5 (because md5 sum calculation with every Apache redirect will be very heavy). These two lines have been transformed to</p>
<blockquote><pre>$filename = preg_replace("@http://[^/]+/(.*)\.$ext$@", "$1", get_request( 'src', 'timthumb' ));
$cachename = $filename . '-' .
	get_request( 'w', 100 ) . '-' .
	get_request( 'h', 100 ) . '-' .
	get_request( 'zc', 1 ) . '-' .
	get_request( '9', 80 );
$cache_file = $cachename . '.' . $ext;</pre>
</blockquote>
<p>There are several changes:</p>
<ul>
<li>We have added correct file name calculation (from the website root) &#8211; and removed from it actual file extension (because we need to add some parameters, and this extension is added a bit lower).</li>
<li>We have just added dashes in <code>$cachename</code> for better readability.</li>
<li>And we have removed <code>md5</code> from <code>$cache_file</code>.</li>
</ul>
<p>So we have replaced initial 2 lines with these 7 ones.</p>
<p>Also we need to change default cache directory to the website root (so all thumbnails will be placed exactly near source files). It&#8217;s line 39 in file <code>timthumb.php</code>:</p>
<blockquote><pre>$cache_dir = './';</pre>
</blockquote>
<p>Please change it to the following one.</p>
<blockquote><pre>$cache_dir = '../../../';</pre>
</blockquote>
<p>OK. Now all our images are placed regarding there location in the website structure. It&#8217;s a half of our optimization.</p>
<h3>Finishing with <code>.htaccess</code></h3>
<p>The last part is to add some RewriteEngine magic to our <code>.htaccess</code>. Let&#8217;s find there the following strings (in <code>BEGIN WordPress</code> part).</p>
<blockquote><pre>RewriteEngine On
RewriteBase /</pre>
</blockquote>
<p>The last one can be commented or absent &#8211; it isn&#8217;t required if we are working with WordPress located in the document root of the website. OK. Please insert here (under these rules) the following lines.</p>
<blockquote><pre>RewriteCond %{SCRIPT_FILENAME} timthumb\.php
RewriteCond %{QUERY_STRING} src=http:\/\/[^\/]+\/(.*)\.(png|jpe?g)&#038;w=([0-9]+)&#038;h=([0-9]+)&#038;zc=([0-9]+)
RewriteCond YOUR_HOME_DIRECTORY/%1-%3-%4-%5-80.%2 -f
RewriteRule .* /%1-%3-%4-%5-80.%2 [L]</pre>
</blockquote>
<p>This can be a bit complicated but let&#8217;s review what they perform. The first one</p>
<blockquote><pre>RewriteCond %{SCRIPT_FILENAME} timthumb\.php</pre>
</blockquote>
<p>checks if any dynamic image (served via <code>timthumb.php</code>) is requested.</p>
<p>The second one</p>
<blockquote><pre>RewriteCond %{QUERY_STRING} src=http:\/\/[^\/]+\/(.*)\.(png|jpe?g)&#038;w=([0-9]+)&#038;h=([0-9]+)&#038;zc=([0-9]+)</pre>
</blockquote>
<p>computes GET parameters (from query string) to get image file name, its extension, width, and height. Please note there is no quality parameter. If your images URLs look different (with additional GET parameter) please add it to this rule.</p>
<p>The third one </p>
<blockquote><pre>RewriteCond YOUR_HOME_DIRECTORY/%1-%3-%4-%5-80.%2 -f</pre>
</blockquote>
<p>checks if there is file with requested name (we create such files after the first request with fixes to <code>timthumb.php</code> described above). Variables (<code>%1</code>, <code>%2</code>, <code>%3</code>, <code>%4</code>, <code>%5</code>) are computed from the second rule (expressions in curly brackets).</p>
<p><strong>Small note:</strong> how to get your home directory? Some of WordPress plugins can your this information but you can also create in the website root a file <code>rootdir.php</code> with the following content</p>
<blockquote><pre>&lt;?php echo $_SERVER['DOCUMENT_ROOT'] ?&gt;</pre>
</blockquote>
<p>and copy its output (after you open it in browser). It will be YOUR_HOME_DIRECTORY. Please don&#8217;t forget to delete this file after you get this info.</p>
<p>And the last Rewrite rule</p>
<blockquote><pre>RewriteRule .* /%1-%3-%4-%5-80.%2 [L]</pre>
</blockquote>
<p>just redirects (internally, without no subsequent redirect &#8211; flag <code>[L]</code>) to the end file name. Great.</p>
<p>All this has resulted into less response time.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/021-3.png" alt="Statified dynamic images" title="Statified dynamic images" width="710" height="217" class="alignnone size-full wp-image-342" /></p>
<p>Not 12ms for the really static file but also not 20ms for dynamic (cached) image.</p>
<h3>Conclusion</h3>
<p>With quite a few changes in <code>timthumb.php</code> and <code>.htaccess</code> we can gain a bit more performance from our website and get it ready for multiple domains usage (which will be discussed in the next blog post). For the home page <strong>actual savings are about 15-20ms</strong>, or less than 1% (because all images are load in 3-4 chunks of parallel flows). This improvement can save a bit for dedicated server but for a shared hosting it improves the whole website efficiency (because we save server expenses and can show more pages to our visitors without overload).</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=10.0" /></div><div>Rating: 10.0/<strong>10</strong> (2 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>January 8, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/08/the-right-way-to-speed-up-your-blog/" title="The right way to speed up your blog">The right way to speed up your blog</a> (3)</li><li>January 7, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/07/is-my-wordpress-blog-fast-enough-part-2/" title="Is my WordPress blog fast enough? (part 2)">Is my WordPress blog fast enough? (part 2)</a> (4)</li><li>January 6, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/06/is-my-wordpress-blog-fast-enough-or-not/" title="Is my WordPress blog fast enough? (part 1)">Is my WordPress blog fast enough? (part 1)</a> (4)</li><li>January 15, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/15/40x-speedup-with-server-side-caching-which-one-is-the-best/" title="40x speedup with server side caching, which one is the best?">40x speedup with server side caching, which one is the best?</a> (0)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=q2CaksLOtKQ:uOywlVmlY0A:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=q2CaksLOtKQ:uOywlVmlY0A:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=q2CaksLOtKQ:uOywlVmlY0A:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=q2CaksLOtKQ:uOywlVmlY0A:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=q2CaksLOtKQ:uOywlVmlY0A:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=q2CaksLOtKQ:uOywlVmlY0A:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=q2CaksLOtKQ:uOywlVmlY0A:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=q2CaksLOtKQ:uOywlVmlY0A:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=q2CaksLOtKQ:uOywlVmlY0A:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=q2CaksLOtKQ:uOywlVmlY0A:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=q2CaksLOtKQ:uOywlVmlY0A:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/q2CaksLOtKQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/01/26/statify-dynamic-images-from-timthumb/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/01/26/statify-dynamic-images-from-timthumb/</feedburner:origLink></item>
		<item>
		<title>Creating CSS Sprites: drawbacks and challenges</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/BairK2g05fo/</link>
		<comments>http://www.speedingupwebsite.com/2010/01/24/creating-css-sprites-drawbacks-and-challenges/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 23:53:59 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[Auto Sprites]]></category>
		<category><![CDATA[CSS Spiites]]></category>
		<category><![CDATA[icons]]></category>
		<category><![CDATA[spriteme]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=320</guid>
		<description><![CDATA[
In the last post we reviewed CSS Sprites technique usage but we didn&#8217;t mention all possible ways to use CSS background property including different image formats. Let&#8217;s deep into this area and list all possible combinations where background images can be used.
Simple usage
Some applications were reviewed a day ago &#8211; we can define for our [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/020.png" alt="Creating CSS Sprites" title="Creating CSS Sprites" width="550" height="226" class="alignnone size-full wp-image-321" /></p>
<p>In the last post we reviewed <a href="http://www.speedingupwebsite.com/2010/01/23/css-sprites-revealing-sealed-myster/">CSS Sprites technique usage</a> but we didn&#8217;t mention all possible ways to use CSS <code>background</code> property including different image formats. Let&#8217;s deep into this area and list all possible combinations where background images can be used.</p>
<h3>Simple usage</h3>
<p>Some applications were reviewed a day ago &#8211; we can define for our image width and height, and place as a background image with the same width and height. As you can remember from post about <a href="http://www.speedingupwebsite.com/2010/01/21/add-more-caching-wit-background-images/">moving images to CSS background</a> we can operate with small images like this one.</p>
<p><img src="/wp-content/themes/basicpress/images/rss_32.png" alt="RSS icon" title="RSS icon" width="32" height="32"/></p>
<p>And add for them styles like these rules.</p>
<blockquote><pre>.img_rss32 {
	width: 32px;
	height: 32px;
	background-image: url(/wp-content/themes/basicpress/images/rss_32.png);
	background-repeat:  no-repeat;
}</pre>
</blockquote>
<p>Here we have an image (RSS icon) 32&#215;32 and create placeholder for it (<code>.img_rss32</code>) with the same dimensions.</p>
<p>This situation is very common for buttons and rollover effects. At the end of design to HTML transformation you can have dozens of images with identical dimensions. And all of them can be simply merged. As an example we will take a CSS Sprite from the previous post.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/webo.256d549f4a.png" alt="CSS Sprite" title="CSS Sprite" width="128" height="168"/></p>
<p>To cut a RSS icon from this image we need to get somehow (is you calculate coordinates during CSS Sprite merging or use automated services &#8211; this shouldn&#8217;t be a trouble) its top-left position. In this case it&#8217;s 92,0. That&#8217;s great.</p>
<p>Then we need to shift background image in backward direction to fit this position. Our styles will look like</p>
<blockquote><pre>.img_rss32 {
	width: 32px;
	height: 32px;
	background-image: url(/wp-content/uploads/2010/01/webo.256d549f4a.png);
	background-repeat: no-repeat;
	<strong>background-position: -92px 0</strong>;
}</pre>
</blockquote>
<p>And here we have our positioned background image.</p>
<div style="width:32px;height:32px;background:url(/wp-content/uploads/2010/01/webo.256d549f4a.png) -92px 0 no-repeat"></div>
<p>Please note that we can place any number of images together if we deal only with such simple usage of background images. But please note that there are some side effects on scaling such elements. So please add a few transparent (or with proper background color) pixels around initial images (5 will be enough).</p>
<h3>Styling lists</h3>
<p>Lists often have custom bullets.  To make them cross browser they are placed with the help of background images. Simple example:</p>
<blockquote><pre>li {
	background-image: url(list.png);
	background-repeat: no-repeat;
	background-position: 0 10px;
}</pre>
</blockquote>
<p>Well. Here we have (a) element with no dimension properties (width / height) and (b) initial background position. The second point can be defeated if we just shift out initial image (<code>list.png</code>) to this position to leave enough free space. But what can we do with the first point?</p>
<p>So while creating HTML/CSS code from initial design mockup we <strong>must</strong> think how to optimize it in the future. And set dimensions for our elements with background images in all possible cases. So tools like <a href="http://spriteme.org/" rel="nofollow">SpriteMe</a> or <a href="http://sprites.in/">Auto Sprites</a> can parse these rules easily.</p>
<p>But let&#8217;s return back to our situation. We can&#8217;t safely merge such images (with undefined dimensions) as far as content can enlarge and visitors will see other images revealed. </p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/020-1.png" alt="Lists background images" title="Lists background images" width="128" height="168" class="alignnone size-full wp-image-329" /></p>
<p>Here is content in the red rectangle, and images from CSS Sprites are &#8216;broken&#8217; (shown incorrectly). So what we do in this case? First of all &#8211; define strict limits for our containers. If we can&#8217;t &#8211; we can place all images suing enough space (i.e. if your containers are limited horizontally you can place your icons one by one horizontally). Also you can try to place them vertically (like in this example) and hope that there won&#8217;t be so much content.</p>
<p>But is there the universal solution? Definitely yes. You can place all background images in such order.</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/020-2.png" alt="Icons like steps" title="Icons like steps" width="93" height="88" class="alignnone size-full wp-image-330" /></p>
<p>This guarantees that any amount of content won&#8217;t break your layout.</p>
<h3>Calculating percentages</h3>
<p>This part is even more complicated than previous one. Because we may deal not only with absolute <code>background-positoon</code>. It can be also set in per cent. And how such images can be merged into Sprites?</p>
<p>If you are really interested in CSS Sprites generation and best practices you must read <a href="http">Steve Souders</a> thoughts about SpriteMe creation (<a href="http://www.stevesouders.com/blog/page/2009/09/14/spriteme/" rel="nofollow">part 1</a> and <a href="http://www.stevesouders.com/blog/2009/09/18/spriteme-part-2/" rel="nofollow">part 2</a>). These techniques can be really hard for beginners and should be left for professionals or persons who are trying to be them.</p>
<p>In a few words we know absolute dimensions of container element and can re-calculate <code>background-position</code> to absolute values. Then handle images as described above.</p>
<p>Also there should be mentioned that not all cases can be converted to CSS Sprites. For example there can be an image placed to an element with not defined (or floating) dimensions with</p>
<blockquote><pre>background-position: 100% 100%;</pre>
</blockquote>
<p>This prevents efficient CSS Sprites usage. Also cases with <code>50% 50%</code> are usually not convertible.</p>
<h3>PNG8, PNG32, and animated GIF</h3>
<p>Different image formats add little more mess to CSS Sprites creation. At this moment all images with 256 colors (and 1-bit transparency) can be safely converted to PNG (yes, without gAMA and all the other chunks to prevent any color inconsistency bugs in browsers). But usually CSS Sprites contain dozens of images. So 256 colors will be not enough to perform this. And we will need to use PNG24.</p>
<p>Using PNG24 be careful with alpha channel. Maybe it&#8217;s safer to separate semi-transparent images from the others and place them in different CSS Sprite.</p>
<p>A few words about animated GIF. It seems they can be safely merged only with other animated GIF images. Because GIF images are usually bigger than PNG equivalents. And please don&#8217;t create CSS Sprites in GIF. It&#8217;s an old school terrible practice.</p>
<h3>Conclusion</h3>
<p>In this post we haven&#8217;t achieved any acceleration for our blog but reviewed some best practice to prepare our website to the extreme performance (and avoid additional handy work). CSS Sprites seems to be very useful approach to reduce number of <a href="http://www.speedingupwebsite.com/2010/02/05/fighting-http-requests-combine-images/">HTTP requests</a>. But they must be replaced with easier techniques, such as data:URI packets or something similar.</p>
<p>But before we have 99% of browsers supporting such techniques we have to use CSS Sprites. So you are forewarned is forearmed. And don&#8217;t create stupid CSS leading to awful CSS Sprites <img src='http://www.speedingupwebsite.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>10</strong> (0 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>January 29, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/" title="Reviewing speedup &#8211; from advanced to extreme website acceleration">Reviewing speedup &#8211; from advanced to extreme website acceleration</a> (0)</li><li>January 23, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/23/css-sprites-revealing-sealed-myster/" title="CSS Sprites: revealing sealed mystery">CSS Sprites: revealing sealed mystery</a> (1)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=BairK2g05fo:DAre7KUDeXw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=BairK2g05fo:DAre7KUDeXw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=BairK2g05fo:DAre7KUDeXw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=BairK2g05fo:DAre7KUDeXw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=BairK2g05fo:DAre7KUDeXw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=BairK2g05fo:DAre7KUDeXw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=BairK2g05fo:DAre7KUDeXw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=BairK2g05fo:DAre7KUDeXw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=BairK2g05fo:DAre7KUDeXw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=BairK2g05fo:DAre7KUDeXw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=BairK2g05fo:DAre7KUDeXw:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/BairK2g05fo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/01/24/creating-css-sprites-drawbacks-and-challenges/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/01/24/creating-css-sprites-drawbacks-and-challenges/</feedburner:origLink></item>
		<item>
		<title>CSS Sprites: revealing sealed mystery</title>
		<link>http://feedproxy.google.com/~r/SpeedingUpWebsite/~3/UGZvSeghi5k/</link>
		<comments>http://www.speedingupwebsite.com/2010/01/23/css-sprites-revealing-sealed-myster/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 00:42:54 +0000</pubDate>
		<dc:creator>WEBO Software</dc:creator>
				<category><![CDATA[Client Side Performance]]></category>
		<category><![CDATA[csprites]]></category>
		<category><![CDATA[css sprites]]></category>
		<category><![CDATA[data:URI]]></category>
		<category><![CDATA[spriteme]]></category>
		<category><![CDATA[sprites.in]]></category>
		<category><![CDATA[webo site speedup]]></category>

		<guid isPermaLink="false">http://www.speedingupwebsite.com/?p=303</guid>
		<description><![CDATA[
Last posts figured out how to use data:URI combined approach (parts 1, 2, 3). The last one actually was related to improving overall website caching not just base64-embed images. And this will help us to create CSS Sprites properly.
CSS Sprites is an important part of overall website acceleration process because (like data:URI) it allows you [...]<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=9.0" /></div><div>Rating: 9.0/<strong>10</strong> (1 vote cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/019.png" alt="CSS Sprites" title="CSS Sprites" width="550" height="226" class="alignnone size-full wp-image-304" /></p>
<p>Last posts figured out how to use <code>data:URI</code> combined approach (parts <a href="http://www.speedingupwebsite.com/2010/01/20/datauri-is-the-next-generation-of-acceleration/">1</a>, <a href="http://www.speedingupwebsite.com/2010/01/20/even-faster-styles-with-data-uri/">2</a>, <a href="http://www.speedingupwebsite.com/2010/01/21/add-more-caching-wit-background-images/">3</a>). The last one actually was related to improving overall website caching not just base64-embed images. And this will help us to create CSS Sprites properly.</p>
<p>CSS Sprites is an important part of overall website acceleration process because (like <code>data:URI</code>) it allows you to create a few objects from 100+. And therefore reduce number of <a href="http://www.speedingupwebsite.com/2010/02/05/fighting-http-requests-combine-images/">HTTP requests</a> which are required to get the layout data of our website. Actual number of CSS Sprites images can be only 2-3 but they can be loaded in parallel and don&#8217;t delay somehow page load (because CSS Sprites are raw images and are not CSS or resource files).</p>
<h3>What are CSS Sprites?</h3>
<p>There are a lot of articles about this revolutionary approach. Really. You can start with classical <a href="www.alistapart.com/articles/sprites" rel="nofollow">&#8216;Image Slicing&#8217;s Kiss of Death&#8217;</a> (A List Apart) and go on reading manuals, reviews and how-to (also you can refer to this <a href="http://www.smashingmagazine.com/2009/04/27/the-mystery-of-css-sprites-techniques-tools-and-tutorials/" rel="nofollow">good article on Smashing Magazine</a>). In a few words CSS Sprite is a combined image which contains 2 or more different background images. Latter images are cut from the CSS Sprite with the help of <code>background-position</code> CSS property (or sometimes via <code>clip</code>).</p>
<p>For example let&#8217;s take this image</p>
<p><img src="http://media.smashingmagazine.com/cdn_smash/images/css-sprites/button.gif" alt="CSS Sprites example" title="CSS Sprites example" width="471" height="27"/></p>
<p>And apply it as a background image for these 2 classes:</p>
<blockquote><pre>.sprite1 {
	background-image: url(.../cdn_smash/images/css-sprites/button.gif);
	background-repeat: no-repeat;
	<strong>background-position: -157px 0;</strong>
	<strong>width: 157px;</strong>
	height: 27px;
}
.sprite2 {
	background-image: url(.../cdn_smash/images/css-sprites/button.gif);
	background-repeat: no-repeat;
	<strong>background-position: -314px 0;</strong>
	<strong>width: 157px;</strong>
	height: 27px;
}</pre>
<p></blockqute><br />
And then just insert <code>&lt;div class="sprite1"&gt;&lt;/div&gt;</code> and <code>&lt;div class="sprite2"&gt;&lt;/div&gt;</code> here:</p>
<div style="background:url(http://media.smashingmagazine.com/cdn_smash/images/css-sprites/button.gif) -157px 0 no-repeat;width:157px;height:27px"></div>
<div style="background:url(http://media.smashingmagazine.com/cdn_smash/images/css-sprites/button.gif) -314px 0 no-repeat;width:157px;height:27px""></div>
<p>As you can see both <code>div</code> have the same background image but look different. The magic is in the position of the background image and blocks&#8217; width (which is also used to cut initial background image).</p>
<h3>Tools to create CSS Sprites</h3>
<p>Now there a large variety of different tools, more or less known. You can start with these handy ones &#8211; <a href="http://spritegen.website-performance.org/" rel="nofollow">spritegen.website-performance.org</a> or <a href="http://css-sprit.es/" rel="nofollow">css-sprit.es</a>. With these tools you need to upload all images and get them placed somehow (hopefully correctly). Also you can&#8217;t add there initial CSS rules &#8211; you just get final ones.</p>
<p>Smart Sprites (<a href="http://csssprites.org/" rel="nofollow">csssprites.org</a>) are much better. They allow you to upload only a prepared CSS file (with absolute paths to images) and get it with CSS Sprites included. But you need to add some more meta information about images to get them merged correctly.</p>
<p>There is also a completely automated approach which was presented last year by <a href="http://stevesouders.com/" rel="nofollow">Steve Souders</a>. It&#8217;s <a href="http://spriteme.org/" rel="nofollow">SpriteMe</a>. You just need to open your website in browser, run this tool and get all images distributed via a few CSS Sprites + a pack of CSS. Then you need to save images and add new styles. No preparations &#8211; just run and apply. Very easy.</p>
<p>If you are looking for a server side approach &#8211; there is <a href="http://sprites.in/">sprites.in</a>. Based on <a href="http://csstidy.sourceforge.net/" rel="nofollow">CSS Tidy</a> parser gets all CSS rules and prepares final CSS Sprites according to these rules. Actually no more than 3 images are created from 100+.</p>
<h3>WordPress plugins</h3>
<p>There is one plugin &#8211; <a href="http://wordpress.org/extend/plugins/csprites-for-wordpress/" rel="nofollow">cSprites</a> &#8211; but it creates not CSS Sprites but HTML ones (Image Maps). All images on website page are replaced with a transparent gif file with the same size but different background. And all images are combined into one.</p>
<p>As an example &#8211; <a href="http://www.speedingupwebsite.com/wp-content/plugins/csprites-for-wordpress/cache/b34e05c83d61096617379b94aeefb6e0.png" rel="nofollow">here is a Sprite</a> from <a href="http://www.speedingupwebsite.com/2010/01/21/add-more-caching-wit-background-images/">the previous post</a>. All there images are combines into 1 (57 Kb in size).</p>
<p>This approach is generally good but can&#8217;t be used with a lot of images. Also it&#8217;s not applicable for the whole website &#8211; different images are created for each page. And if you have some layout images &#8211; they will be added to each Sprite (we discussed <a href="http://www.speedingupwebsite.com/2010/01/21/add-more-caching-wit-background-images/">how to move images from HTML to CSS</a>, this can help).</p>
<p>Also due to large images this plugin will be very costly for server side (in terms of memory). With our restriction in 32 Mb home page was broken during such <a href="http://www.speedingupwebsite.com/2010/01/08/the-right-way-to-speed-up-your-blog/">WordPress performance optimization</a>. And there is no option to restrict images by file name or size.</p>
<p>And finally computed styles are inserted via JavaScript (<code>document.write</code>) into document body. This definitely freezes rendering and such images appearance.</p>
<h3><a href="http://wordpress.org/extend/plugins/web-optimizer/" rel="nofollow">WEBO Site SpeedUp</a></h3>
<p>But speaking about completely automated CSS Sprites we must mention one more WordPress plugin. Frankly speaking it integrates functionality of <a href="http://sprites.in/">sprites.in</a> tool but brings to a new level. It also has large variety of options for CSS Sprites processing (restriction by size or filename). We definitely need to cover CSS Sprites tuning with the help of this plugin in the next blog posts.</p>
<p>But now we have just tried to create a sample (yes, we have a few background images appeared after moving them from HTML to CSS). And our final Sprite image looks like the following one:</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/webo.256d549f4a.png" title="WEBO Site SpeedUp CSS Sprite" alt="WEBO Site SpeedUp CSS Sprite" width="128" height="168"/></p>
<p>It seems the whole logic works almost perfectly &#8211; the image isn&#8217;t too large and all transparency is handled properly. Great. But what&#8217;s about our website speedup?</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/019-1.png" alt="YSlow chart" title="YSlow chart" width="447" height="262" class="alignnone size-full wp-image-309" /></p>
<p>If you compare it with the previous one</p>
<p><img src="http://www.speedingupwebsite.com/wp-content/uploads/2010/01/018-2.png" alt="YSlow chart" title="YSlow chart" width="439" height="239" class="alignnone size-full wp-image-297" /></p>
<p>you can see that for our website (after <code>data:URI</code> over CSS Sprites with WEBO Site SpeedUp) we have 9 Kb more data. It seems in our case CSS Sprites are useless. But if final images are greater than 24 Kb (IE8 data:URI size restriction) &#8211; they will be loaded as plain images what should increase concurrency of load flows. And please also take into accordance that IE7@Vista supports <code>mhtml</code> (base64-encoded images) badly. So we still need to use CSS Sprites for this browser.</p>
<h3>Conclusion</h3>
<p>CSS Sprites is a very powerful tool to increase website load speed and decrease number of HTTP requests. There are several approaches (handy and automated) to create them but be careful with website size, memory limits, and compatibility. We will analyze correct CSS Sprites creation process and drawbacks of such approach (yes, there are several onew) in the next posts.</p>
<br /><div><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx.php?value=9.0" /></div><div>Rating: 9.0/<strong>10</strong> (1 vote cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://www.speedingupwebsite.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br /><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>February 21, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/21/html-sprites-new-weapon-against-http-requests/" title="HTML Sprites &#8211; new weapon against HTTP requests">HTML Sprites &#8211; new weapon against HTTP requests</a> (2)</li><li>January 21, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/21/add-more-caching-wit-background-images/" title="Add more caching with (background) images">Add more caching with (background) images</a> (0)</li><li>February 26, 2010 -- <a href="http://www.speedingupwebsite.com/2010/02/26/all-about-wordpress-performance-11-golden-rules/" title="All about WordPress performance &#8211; 11 golden rules">All about WordPress performance &#8211; 11 golden rules</a> (1)</li><li>January 29, 2010 -- <a href="http://www.speedingupwebsite.com/2010/01/29/reviewing-speedup-from-advanced-to-extrem-website-accelerati/" title="Reviewing speedup &#8211; from advanced to extreme website acceleration">Reviewing speedup &#8211; from advanced to extreme website acceleration</a> (0)</li></ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=UGZvSeghi5k:LG72ORZ1qSI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=UGZvSeghi5k:LG72ORZ1qSI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=UGZvSeghi5k:LG72ORZ1qSI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=UGZvSeghi5k:LG72ORZ1qSI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=UGZvSeghi5k:LG72ORZ1qSI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=UGZvSeghi5k:LG72ORZ1qSI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=UGZvSeghi5k:LG72ORZ1qSI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=UGZvSeghi5k:LG72ORZ1qSI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=UGZvSeghi5k:LG72ORZ1qSI:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?a=UGZvSeghi5k:LG72ORZ1qSI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SpeedingUpWebsite?i=UGZvSeghi5k:LG72ORZ1qSI:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SpeedingUpWebsite/~4/UGZvSeghi5k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.speedingupwebsite.com/2010/01/23/css-sprites-revealing-sealed-myster/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.speedingupwebsite.com/2010/01/23/css-sprites-revealing-sealed-myster/</feedburner:origLink></item>
	</channel>
</rss>
