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

<channel>
	<title>Michael Forbes - User Experience Engineer &#187; website optimization</title>
	<atom:link href="http://mrforbes.com/blog/category/website-optimization/feed/" rel="self" type="application/rss+xml" />
	<link>http://mrforbes.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 20 Feb 2012 04:23:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Optimizing This Site, Part II: Use a CDN</title>
		<link>http://mrforbes.com/blog/2009/01/optimizing-this-site-part-ii-use-a-cdn/</link>
		<comments>http://mrforbes.com/blog/2009/01/optimizing-this-site-part-ii-use-a-cdn/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 03:48:16 +0000</pubDate>
		<dc:creator>michael</dc:creator>
				<category><![CDATA[website optimization]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://www.mrforbes.com/?p=127</guid>
		<description><![CDATA[Where I add a CDN, and my Yslow score jumps. <a href="http://mrforbes.com/blog/2009/01/optimizing-this-site-part-ii-use-a-cdn/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The second recommendation yahoo makes is to use a CDN &#8211; or Content Delivery Network.  The idea of a CDN is to take the uploaded files, and distribute them to servers around the world, so when a file is requested it is served from the nearest/lowest latency server.  The secondary benefit is that this also offloads some of the processing power from your server, to an entire network of servers &#8211; whose whole purpose is to serve your files as quickly as possible.<br />
<span id="more-127"></span><br />
Since these are merely file servers and nothing more, generally only static content is suitable to be put onto a CDN &#8211; things like javascripts, stylesheets, and images.</p>
<p>Initially, I was planning to use Amazon&#8217;s Cloudfront CDN, because it is very low cost and has Amazon backing it. However, during my research I discovered that Cloudfront is not website optimization friendly.  Specifically, it isn&#8217;t a simple process to gzip files, or to set expires headers on them so they get cached.  For the sake of time, I wanted something simple.  I saw a few comments about <a href="http://www.simplecdn.com">SimpleCDN</a> &#8211; which is actually lower cost than Cloudfront, and supports those optimization methods out of the box.  One short account later, and I was ready to rock.</p>
<p>SimpleCDN offers three modes of getting your files onto their service.  I chose to use their upload tool, because while it is the most manual labor, it also offer the most fine-grained control over the files being uploaded.  All you need to do is login to their admin tool, create a &#8216;bucket&#8217; &#8211; which is really just a folder that holds your files, and them use the provided ftp info to login to the &#8216;bucket&#8217; and upload your files.  You can then CNAME a domain (in my case cdnc.mrforbes.com) to the service.  They give you plenty of options on how you want to serve your files &#8211; zipped or not zipped, headers set to expire after a day, 3 days, etc&#8230;  At that point, its just a matter of pointing your files to the right place in your code, and your good to go.</p>
<h4>Results</h4>
<p>If you recall, we ended <a href="/thoughts/2009/01/19/optimizing-this-site-part-i-reducing-http-requests/">Part 1 </a>with a YSlow score of 61, and an average load time of around 2 seconds.  This is pretty fast, but we&#8217;ll see how a CDN helps us out.  Our grade on this YSlow metric is currently an F.</p>
<p>I followed the procedure above, and got all of my files up onto the CDN.  The one thing to keep in mind here is if you change any of the files, you generally need to rename them, relink them in the code, and re-upload them.. otherwise you&#8217;ll be waiting for CDN to re-propagate, which can take up to 24 hours.  Completing this, I ran YSlow again.</p>
<p>[singlepic id=9 w=295 h=150 float=right]  If you expand the image, you&#8217;ll see that my site now received a Yslow score of 98.  Before you start thinking a CDN is the answer to all things optimized &#8211; keep in mind that the CDN is also gzipping and caching the files it is serving, which are other recommendations for website optimization.  Essentially, by adding SimpleCDN I changed 3 scores, not one.   My only question is, if I have all As, why did I get a 98? How do I get 100?</p>
<ol class="samples">
<li>
<table>
<tr>
<th>Initial YSlow Score:</th>
<td>D(61)</td>
<th>Final YSlow Score:</th>
<td>A(98)</td>
</tr>
<tr>
<th>Initial Page Size:</th>
<td>500k</td>
<th>Final Page Size:</th>
<td>400k</td>
</tr>
<tr>
<th>Initial Load Time:</th>
<td>2+ seconds</td>
<th>Final Load Time</th>
<td>1.5+ seconds</td>
</tr>
</table>
</li>
</ol>
<p>*Update:  I have since added a few WordPress plugins which are loading their own images and stylesheets, so if you run YSlow on my site you won&#8217;t get the same numbers I have here.  I plan to optimize again once I have decided on final functionality for the site.</p>
]]></content:encoded>
			<wfw:commentRss>http://mrforbes.com/blog/2009/01/optimizing-this-site-part-ii-use-a-cdn/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Optimizing This Site, Part I: Reducing HTTP requests</title>
		<link>http://mrforbes.com/blog/2009/01/optimizing-this-site-part-i-reducing-http-requests/</link>
		<comments>http://mrforbes.com/blog/2009/01/optimizing-this-site-part-i-reducing-http-requests/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 04:57:57 +0000</pubDate>
		<dc:creator>michael</dc:creator>
				<category><![CDATA[website optimization]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://s52837.gridserver.com/?p=121</guid>
		<description><![CDATA[Where I combine css and javascript files, and put as many images into css sprites as possible <a href="http://mrforbes.com/blog/2009/01/optimizing-this-site-part-i-reducing-http-requests/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>According to YSlow, I received an F for the number of http requests made by my homepage.  This page currently has 23 http requests, including 12 javascript files and 5 css files.  This is way too many, and we need to bring this number down.  <a href="http://developer.yahoo.com/performance/rules.html">Here is a link</a> to what Yahoo has to say about reducing HTTP requests.  I&#8217;ll list my updates in the same order.<br />
<span id="more-121"></span></p>
<ol class="normal">
<li>
<h4>Combined Files</h4>
<p>It makes sense that the first thing I should do is combine those javascript and css files.  I certainly don&#8217;t need 17 when 2 or 3 will do just fine.  So, what I&#8217;m going to do is take all of my separate javascript files, open them up, and copy and paste the code into one large file.  Yes, this makes editing a little more time consuming, since you need to navigate a whole huge file to get the piece you want.  Luckily, there are plugins available for different programming languages which will do this for you (pack:tag for java is an example).  That way you can edit your original code, save it, and let the server handle this step.  My site is simple, and if you aren&#8217;t that technically inclined, this method works so I&#8217;m outlining it here.
</p>
<p>Next, I&#8217;m going to do the same with the stylesheets.  When I load YSlow and click on &#8216;components&#8217;, I see that one of my wordpress plugins is loading 2 stylesheets, so even with combining my own two I will still be loading three.  I don&#8217;t really want this, so I did a search for the file in question, commented it out of the autoloading in the plugin (yes, it will come back if I upgrade and I&#8217;ll have to do it again), and pasted it into my style.css.
</p>
<p>Now that my files are combined, I&#8217;ll move on to the next recommended step.</p>
</li>
<li>
<h4>CSS Sprites, Image Maps, Inline Images</h4>
<p>Okay, I cheated a little bit because I did this when I exported the original PSD.  There are a few non-css-sprited images on the homepage, but they are there of necessity.   The background, because its very wide and needs to repeat.  The ocean in the footer for the same reason (which is also a png so the island can be seen behind it &#8211; even though a gif would be much smaller in file size),  and the latest creations graphic (which is also currently a png, but I will likely change to a JPG as part of the optimization).  The clouds and balloons are also graphics, but out of necessity &#8211; they need to be resizable.
</p>
<p>Image maps wouldn&#8217;t have really helped me on this design, and to be honest &#8211; I&#8217;m not a fan of inline images.  Until there is a tool that automates their inclusion, adding that kind of code to an html page feels totally contrary to the entire value of CSS.</p>
</li>
<li>
<h4>Wait, let&#8217;s do a little more.</h4>
<p>YSlow Step 10, minimize js, and Step 6 &#8211; put all javascript at the bottom are separate steps, but related to this exercise, so I&#8217;ll take care of them now.  Currently, the site.js file is 173k, quite large.  However, we can compress this by removing comments and whitespace, and shortening variable names.  Again, we don&#8217;t have to do this ourselves.  In fact, we can even do it online <a href="http://yui.2clics.net/">here</a>.   After minimization, that 173k file gets shrunk down to 93k. </p>
<p>As for moving the javascript to the bottom of the page,  I&#8217;ll just take my script and put it into the footer. I see that there are two javascript files being autoloaded into the header by the nggallery plugin.  I want to get those to the bottom too, but will do so at a later time.
</li>
</ol>
<h3>Results</h3>
<ol class="samples">
<li>
<table>
<tr>
<th>Initial YSlow Score:</th>
<td>F(39)</td>
<th>Final YSlow Score:</th>
<td>D(61)</td>
</tr>
<tr>
<th>Initial Requests:</th>
<td>23</td>
<th>Final Requests:</th>
<td>15: 3 js, 2 css, 9 images</td>
</tr>
<tr>
<th>Initial Page Size:</th>
<td>600k</td>
<th>Final Page Size:</th>
<td>500k</td>
</tr>
<tr>
<th>Initial Load Time:</th>
<td>6+ seconds</td>
<th>Final Load Time</th>
<td>2+ seconds</td>
</tr>
</table>
</li>
</ol>
<p>[singlepic id=9 w=298 h=150 float=right]
<p>As you can see from these results, reducing the number of HTTP requests and minimizing our javascripts has increased load times by around 300%. We also raised our YSlow score by over 22 points.  Not bad for about 30 minutes worth of optimizing.</p>
<p>Coming up next &#8211; adding Amazon Cloudfront as a Content Delivery Network</p>
]]></content:encoded>
			<wfw:commentRss>http://mrforbes.com/blog/2009/01/optimizing-this-site-part-i-reducing-http-requests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing This Site, Prelude</title>
		<link>http://mrforbes.com/blog/2009/01/optimizing-this-site-prelude/</link>
		<comments>http://mrforbes.com/blog/2009/01/optimizing-this-site-prelude/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 04:40:28 +0000</pubDate>
		<dc:creator>michael</dc:creator>
				<category><![CDATA[website optimization]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://s52837.gridserver.com/?p=116</guid>
		<description><![CDATA[Introduction to tracking each optimization step to see how this site improves. <a href="http://mrforbes.com/blog/2009/01/optimizing-this-site-prelude/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
As I was redesigning this site, and preparing to redirect my domain to it &#8211; I decided that I would hold off on performing the optimization that is important to every website.  Instead, I thought I would create a series of posts about the process &#8211; step by step so we can all witness how the site improves which each optimization performed.  I&#8217;m going to try to go in the order presented by <a href="http://developer.yahoo.com/performance/">Yahoo</a> and their <a href="https://addons.mozilla.org/en-US/firefox/addon/5369">YSlow firefox plugin</a>, in order to present actual numbers related to the changes.
</p>
<p><span id="more-116"></span></p>
<p>
Currently, the site is totally unoptimized.  I haven&#8217;t removed redundant or unused styles from the CSS.  The javascript isn&#8217;t minified, its in the header, and each plugin is a separate file.  Let&#8217;s see what YSlow starts us with:</p>
<p>[singlepic id=8 w=274 h=150 float=right]<br />
If you enlarge the image, you&#8217;ll see that we&#8217;re starting off with a grade of F&#8230; and a numeric grade of 39.  The current size of the homepage is about 600k, and the time to load is around six seconds. Looks like there&#8217;s a lot of room for improvement there.  The first item of concern for YSlow is the number of http requests, currently topping 17 &#8211; with 12 javascript files and 5 css files.  For our next installment, we&#8217;ll try to reduce this as close to 1 and 1 as possible.</p>
<p>See you then.</p>
]]></content:encoded>
			<wfw:commentRss>http://mrforbes.com/blog/2009/01/optimizing-this-site-prelude/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

