<?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>klauskomenda.com &#187; Performance</title>
	<atom:link href="http://www.klauskomenda.com/archives/category/web/coding/performance/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.klauskomenda.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 14 Dec 2011 23:58:35 +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>CSS Reviewr</title>
		<link>http://www.klauskomenda.com/archives/2008/12/20/css-reviewr/</link>
		<comments>http://www.klauskomenda.com/archives/2008/12/20/css-reviewr/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 20:17:58 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=740</guid>
		<description><![CDATA[Check your CSS code against certain standards and best practices. Brought to you by Santa Klaus. Merry Christmas. ]]></description>
			<content:encoded><![CDATA[<p>There is <a href="http://www.jslint.com/">JSLint</a> for JavaScript, <a href="http://pear.php.net/package/PHP_CodeSniffer">PHP_CodeSniffer</a> for PHP&#8230;why not have some sort of code checking tool for CSS? Based on the outcome of several code reviews we had at <a href="http://uk.yahoo.com/">Yahoo! Europe</a>, I thought that it would come in handy having a tool that would catch findings automatically. So over the last couple of months I was working on such a tool and called it <a href="http://www.klauskomenda.com/tools/cssreviewr/">CSS Reviewr</a>.</p>
<p><a href="http://www.klauskomenda.com/tools/cssreviewr/"><img alt="Try out CSS Reviewr" src="http://www.klauskomenda.com/wp-content/uploads/2008/12/cssreviewr_logo.gif" alt="" width="291" height="50" class="img-right" /></a>It is quite similar to a couple of tools that are already out there. JSLint looks for issues in JavaScript code and checks for adherence to a certain set of code standards. PHP_CodeSniffer, a <a href="http://pear.php.net/">PEAR</a> package, provides similar functionality for PHP files (but is also able to check JavaScript and CSS). Then there is <a href="http://csstidy.sourceforge.net/">CSSTidy</a>, a parser and optimiser for CSS, which e.g. compresses hex values for color declarations and provides different levels of minification (removing comments, whitespace etc.). </p>
<p>Essentially, what I wanted to achieve with CSS Reviewr is to not only point out issues in the code based on the experiences and the reviews we conducted at work, but also to provide explanatory text for each finding (much like how the <a href="http://validator.w3.org/">W3C Validator</a> does it for HTML). In one or two sentences, I wanted to explain why this is an issue and how it can be resolved. From my perspective, this is ideal for a developer who might not be familiar with a certain best practice or convention. By reading the explanation and maybe following a link to a page that provides more details, it has a certain learning effect to it. </p>
<p>CSS Reviewr, as it is stated on the page, is <em>not</em> a validator. It is encouraged to run your code through the <a href="http://jigsaw.w3.org/css-validator/">W3C CSS Validator</a> first, before checking it using CSS Reviewr.</p>
<p>Last, but not least, I would like to thank the real brain behind this: <a href="http://samriley.net/">Sam Riley</a>. I had the pleasure of working with him on <a href="http://answers.yahoo.com/">Yahoo! Answers</a> and I was and am still really impressed by his sheer endless knowledge of the ins and outs of CSS. Knowing that I would not be able to just turn to the side and ask him whenever I have a question related to CSS (because I relocated from London to California), I wrote this tool also to store his CSS knowledge somewhere for myself, so I could still use it here in the US <img src='http://www.klauskomenda.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  So a big thanks to Sam!. Also thanks to <a href="http://www.evalotta.net/">Eva-Lotta</a>, who kindly offered to do some visual design work for this in her spare time. </p>
<p>The tool is in beta right now and I have already identified <a href="http://www.klauskomenda.com/tools/cssreviewr/package/BUGS">some bugs</a> myself that I need to fix at some point, providing I find time for this. Getting some early feedback from colleagues, I have also received the following feature requests:</p>
<ul>
<li>Indentation check (selectable option)</li>
<li>Check (background) images used in the code are akamized/on a content delivery network (CDN)</li>
<li>Fonts should not use uppercase characters (e.g &#8220;Arial&#8221; should be &#8220;arial&#8221;)</li>
<li>Limit the amount of errors shown to 50 to prevent browser (FF2) from crashing. Add something like: &#8220;More than 50 issues found. Fix the issues above first before checking your code again.&#8221;</li>
<li>Having a &#8216;Do it!&#8217; button by each issue to make the suggested modification to the code, and then have a textarea at the bottom where you could copy out the fixed version</li>
</ul>
<p>Suggestions, bug reports and all kinds of feedback welcome. Just leave a comment below. Thanks and happy holidays!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2008/12/20/css-reviewr/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WordPress Plugin: Shrinkr</title>
		<link>http://www.klauskomenda.com/archives/2008/10/22/wordpress-plugin-shrinkr/</link>
		<comments>http://www.klauskomenda.com/archives/2008/10/22/wordpress-plugin-shrinkr/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 19:55:20 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=683</guid>
		<description><![CDATA["More power!", as Tim Taylor from the TV sitcom "Home Improvement" would say. Don't we all want more power, more performance from our web sites? I was working on a WordPress plugin that enables you to bump up the speed of your site by minification of your CSS and JavaScript files. And now finally found time to release it.]]></description>
			<content:encoded><![CDATA[<p>With higher expectations, both in terms of design and interaction of websites, which are more like web applications these days, the amount and size of JavaScript and CSS files used have increased dramatically during the last couple of years. Ajax, Drag &amp; Drop, Animation&#8230;if your site doesn&#8217;t keep up with the latest trend, you might be left out. But bigger file sizes (and more files) also mean more HTTP requests and having to download more data from the server over an Internet connection, which means slower loading of the page. <a href="http://www.klauskomenda.com/code/wordpress-plugin-shrinkr/">Shrinkr</a> helps you to tackle that problem.</p>
<h2>Description</h2>
<p>Shrinkr does two things:</p>
<ol>
<li>It reduces the file-size of your CSS and JavaScript files through <a href="http://en.wikipedia.org/wiki/Minify">minification</a>, i.e. stripping out unnecessary content like white-space and comments</li>
<li>It then takes those files and concatenates them into one single CSS and one single JavaScript file</li>
<li>Those files are then getting stored as css-min-[timestamp].css and js-min-[timestamp].js on your server. The reason for the timestamp is that whenever Shrinkr creates a new file, it is ensured that a user agent doesn&#8217;t still use a cached version of the previous files but, because the name of the file has changed, retrieves the latest version from the server</li>
</ol>
<p>The first measure reduces the file-size by stripping out things from files that are not needed by the browser in order to interpret them. Whitespace and comments are for developers, not for the browser. They can safely be removed, which reduces the file-size and thus the consumption of bandwidth.</p>
<p>In the <a href="http://developer.yahoo.com/performance/rules.html">Yahoo! Exceptional Performance Rules</a>, it says that one should aim to <a href="http://developer.yahoo.com/performance/rules.html#num_http">reduce the number of HTTP requests</a> in order to make a page load as fast as possible. Shrinkr does that by concatenating all the files into one single file (one for CSS and one for JS). So instead of having 10 CSS files, you will end up having only one.</p>
<p>Shrinkr also adds an action to wp_head and wp_footer in order to tell WordPress to include those files upon page load in the appropriate section of the page. <a href="http://developer.yahoo.com/performance/rules.html#css_top">CSS files should be included in the head of the page</a>, <a href="http://developer.yahoo.com/performance/rules.html#js_bottom">JS at the very bottom</a> as per the Yahoo! Exceptional Performance Rules. </p>
<p>Because of the fact that you will end up having all your CSS and JavaScript in one file and on one line (because all the carriage returns etc. have been stripped out), it makes debugging kind of difficult. For that reason, you should only activate that plugin on the live version of your site and keep the files separated on your development box.</p>
<p>Further details about the plugin can be found on the <a href="http://www.klauskomenda.com/code/wordpress-plugin-shrinkr/">Shrinkr plugin page</a>. It would be great if you could try it out and give me feedback, either by leaving a comment here or using the <a href="/contact/">contact form</a>. Thanks!</p>
<h2>Resources</h2>
<ul>
<li><a href="http://developer.yahoo.com/performance/rules.html">Best Practices for Speeding Up Your Web Site</a></li>
<li><a href="http://developer.yahoo.com/yui/compressor/">Yahoo! UI Library: YUI Compressor</a></li>
<li><a href="http://www.crockford.com/javascript/jsmin.html">JSMIN, The JavaScript Minifier</a></li>
<li><a href="http://code.google.com/p/minify/">Minify!</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2008/10/22/wordpress-plugin-shrinkr/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Measuring Bandwidth with JavaScript</title>
		<link>http://www.klauskomenda.com/archives/2008/04/16/measuring-bandwidth-with-javascript/</link>
		<comments>http://www.klauskomenda.com/archives/2008/04/16/measuring-bandwidth-with-javascript/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 20:45:00 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/archives/2008/04/16/measuring-bandwidth-with-javascript/</guid>
		<description><![CDATA[Most Web Developers have access to broadband Internet connections &#8212; but unfortunately this does not yet reflect the type of connections many Internet users are using. Some might still be on ISDN or even on dial-up. This article is meant to discuss the idea of measuring the user bandwidth using JavaScript and serving different types of content to users depending on their connection speed.]]></description>
			<content:encoded><![CDATA[<p>When I was doing the redesign of my site (actually when I was already finished), I realized that the big header image I was using consumes a lot of bandwidth when downloaded by the user. Subsequently, it added to the page loading time and made the site much heavier than the old version. I really did not want to start tweaking the image and maybe trying to create a 1px background that I would be able to repeat across the width of the site. Also: the size of the image would only be a problem for users with a slow Internet connection &mdash; broadband users would probably not even notice a speed difference to the old site. So I was thinking: Would there be a way of finding out the connection speed of the user and subsequently serve different content (e.g. in this case, maybe just a plain black background and no image at all) to users with e.g. a dial-up connection? I was thinking JavaScript. Maybe.</p>
<h2>Step By Step</h2>
<p>I did some digging on the net and some investigation and tried to come up with a concept that makes sense. The steps I was thinking about:</p>
<ol>
<li>On page load, a 10kB image gets requested &#8220;in the background&#8221; (hidden from the user by CSS)</li>
<li>Via JavaScript, the time it takes to load that image gets recorded and the bandwidth gets calculated</li>
<li>As soon as this process is done, the image gets removed again from the DOM</li>
<li>Some sort of bandwidth cookie gets stored on the client, telling the site which content to serve on subsequent calls to the site</li>
</ol>
<p>I came up with <a href='http://www.klauskomenda.com/wp-content/uploads/2008/04/bandwidthr.html' title='Bandwidthr Source File'>a prototype that demonstrates the bandwidth measuring</a> using JavaScript. It does not take care of Steps 3 and 4 mentioned in the list above, but I think it conveys the idea behind it.</p>
<p>Some things to note about the JavaScript:</p>
<ul>
<li>Line 47: I am using <span class="code">onload</span> as an attribute of the element itself, which is bad practice in general, cause behavior should entirely be controlled using JavaScript and Event Handlers should be added e.g. with <a href="http://developer.yahoo.com/yui/event/">YUI Event</a>. To not waste execution time and maybe alter the measure of the bandwidth, I used it in this instance. Because of that, I also had to author this document in HTML 4.01 strict, to make sure it validates.</li>
<li>Line 52: Also, I am using <span class="code">innerHTML</span> to quickly insert the piece of code that constructs the image element. I could have created the image element using <span class="code">document.createElement</span>, but <span class="code">innerHTML</span> works just fine and occurred to me as just more convenient in this case.</li>
</ul>
<h2>Conclusion</h2>
<p>Honestly, after I was finished with the prototype, I was not really sure if that whole thing makes sense at all. Cause what it does is it makes an <em>additional</em> request to the server which would make the page even <em>slower</em> to load for people already suffering from a slow connection speed. Also, thinking about the cookie thing, as people tend to be mobile these days, they might have a slow (WiFi) connection when requesting the site, but have a fast broadband connection at home. But with the cookie already written when they visited the site when they were mobile, they would get the low-bandwidth-experience at home as well &ndash; which defeats the purpose, kind of.</p>
<p>So especially after writing this blog post about it, I am not really sure if my idea makes sense. So I am asking you guys, what is your opinion on that?</p>
<h2>Resources</h2>
<ul>
<li><a href="http://www.uis.harvard.edu/emerging_technologies/bwtest/">Harvard University Information Systems: Bandwidth Tester</a></li>
<li><a href="http://zigotos.ca/2006/10/30/upload-bandwidth-as-a-bottleneck-to-busy-web-pages/">Upload bandwidth as a bottleneck to busy web pages</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2008/04/16/measuring-bandwidth-with-javascript/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using Dust-Me Selectors Plugin to find unused CSS selectors</title>
		<link>http://www.klauskomenda.com/archives/2008/03/18/using-dust-me-selectors-plugin-to-find-unused-css-selectors/</link>
		<comments>http://www.klauskomenda.com/archives/2008/03/18/using-dust-me-selectors-plugin-to-find-unused-css-selectors/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 10:51:52 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/archives/2008/03/18/using-dust-me-selectors-plugin-to-find-unused-css-selectors/</guid>
		<description><![CDATA[Spring clean your CSS file(s): Get rid of selectors which are not used (any more) and save some bandwidth. With the Dust-Me Selectors Plugin from SitePoint.]]></description>
			<content:encoded><![CDATA[<p>Every Web Developer knows about them and everyone amongst them who cares about performance fears them. Unused zombie-like CSS selectors that were initially added to your CSS files (probably at an early stage of the project) with good intentions but became useless and redundant at some point, most likely because of changes in the markup. So these CSS selectors normally stay there, unless some intern gets hired to find them &#8211; cause a regular Web Developer has far more important things to do, right?</p>
<p>With the <a href="http://www.sitepoint.com/dustmeselectors/">Dust-Me Selectors</a> Firefox extension provided by <a href="http://www.sitepoint.com/">SitePoint</a>, there is a way out of this. The extension provides a convenient way of cleaning up your CSS file(s) and identifying selectors which are not used anymore. </p>
<p><img class="img-left" src='http://www.klauskomenda.com/wp-content/uploads/2008/03/dust-me-browser-bar.gif' alt='Dust-Me Selectors Icon in Browser Bar' />After installation, the presence of the application is indicated by an icon in the browser bar showing a spiffy broom. The extension comes with several options. First, you can select that upon visiting a certain web site, it starts recording which CSS selectors from the CSS files loaded get actually used on the site you are on (indicated by an animated broom icon and listing the amount of unused selectors found in how many CSS files). It then creates a list and bit by bit ticking off every selector being used. While you continue browsing the site, that list (hopefully) gets smaller and after you have browsed through samples of significant pages on your site, it will give you a list of CSS selectors which &#8211; it thinks &#8211; are redundant and can be deleted.</p>
<p><img class="img-left" src='http://www.klauskomenda.com/wp-content/uploads/2008/03/dust-me-spider-sitemap.gif' alt='Dust-Me Selectors Spider Sitemap Window Screenshot' />With <a href="http://www.sitepoint.com/blogs/2007/11/26/dust-me-selectors-version-20/">version 2.0</a>, the clever guys at SitePoint (cause they know what we want) built a spider functionality into Dust-Me. This means that you can provide the extension with a sitemap of your site (either an HTML file with a list of links or a <a href="http://www.sitemaps.org/protocol.php">Sitemap XML file</a>) and it will spider the pages provided (and going one level deep from there). From my perspective a more convenient way, if you have a tool that creates a site map like <a href="http://www.xml-sitemaps.com/">XML-Sitemaps.com Sitemap Generator</a> or <a href="http://gsitecrawler.com/">GSiteCrawler</a>. There is even a <a href="http://www.arnebrachhold.de/projects/wordpress-plugins/google-xml-sitemaps-generator/">Google (XML) Sitemaps Generator for WordPress</a>.</p>
<p><img class="img-left" style="clear: left" src='http://www.klauskomenda.com/wp-content/uploads/2008/03/dust-me-view-data.gif' alt='Dust-Me Selectors View Data Screenshot' />The &#8220;view saved data&#8221; option in the plugin will then give you a nice list of used/unused selectors which will give you a sense of which selectors might be save to delete. I say might, because it does not check whether you might use one or the other CSS selector to style markup you insert via JavaScript into the page. This is beyond the scope of the plugin, so with the final output data from Dust-Me at hand, you will need to check whether one or the other applies to markup added using JavaScript &mdash; and then don&#8217;t delete them, of course <img src='http://www.klauskomenda.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h2 style="clear:both">Further reading</h2>
<ul>
<li><a href="http://www.sitepoint.com/dustmeselectors/">Dust-Me Selectors plugin homepage</a></li>
<li><a href="http://www.sitepoint.com/dustmeselectors/ui/">Plugin User Interface</a></li>
<li><a href="http://www.sitepoint.com/dustmeselectors/preferences/">Plugin Preferences</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2008/03/18/using-dust-me-selectors-plugin-to-find-unused-css-selectors/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Boost Your Web site Performance</title>
		<link>http://www.klauskomenda.com/archives/2007/11/10/boost-your-website-performance/</link>
		<comments>http://www.klauskomenda.com/archives/2007/11/10/boost-your-website-performance/#comments</comments>
		<pubDate>Sat, 10 Nov 2007 16:15:10 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/archives/2007/11/10/boost-your-website-performance/</guid>
		<description><![CDATA[In times where web sites behave more and more like web applications, with a constantly growing set of features, most likely developed with JavaScript, it is still of crucial importance that the web site responds to user actions as fast as possible. A couple of months ago, Yahoo! published a set of Exceptional Performance Rules, [...]]]></description>
			<content:encoded><![CDATA[<p>In times where web sites behave more and more like web applications, with a constantly growing set of features, most likely developed with JavaScript, it is still of crucial importance that the web site responds to user actions as fast as possible. A couple of months ago, <a href="http://www.yahoo.com/">Yahoo!</a> published <a href="http://developer.yahoo.com/performance/rules.html">a set of Exceptional Performance Rules</a>, which &#8211; if you adhere to them &#8211; can improve the performance of your site significantly. So I had a look how these rules can help me to improve the stats for my own site, <a href="http://www.klauskomenda.com/">www.klauskomenda.com</a>.<span id="more-116"></span></p>
<h3>Analyzing the present state</h3>
<p>Equipped with <a href="http://www.getfirebug.com/">Firebug</a> and Yahoo!&#8217;s <a href="http://developer.yahoo.com/yslow/">YSlow</a>, an extension for Firebug, I first had a look at the current performance measures of this site. Firebug reported the following (under the &#8220;Net&#8221; tab, select &#8220;All&#8221;):</p>
<table class="datatable small" cellspacing="0">
<colgroup>
<col />
<col  />
<col  /></colgroup>
<thead>
<tr>
<th>Area</th>
<th># requests</th>
<th>Datasize (in kB)</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3">Overall: 29 requests, 194kB</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>HTML</td>
<td>2</td>
<td>31</td>
</tr>
<tr class="odd">
<td>CSS</td>
<td>5</td>
<td>27</td>
</tr>
<tr>
<td>JavaScript</td>
<td>12</td>
<td>84</td>
</tr>
<tr class="odd">
<td>Images</td>
<td>10</td>
<td>52</td>
</tr>
</tbody>
</table>
<p>YSlow measures a web site&#8217;s performance against the abovementioned Exceptional Performance Rules. It grades the performance for every category and finally comes up with an overall performance score for the whole website. The scores for this site were as follows:</p>
<table  class="datatable" cellspacing="0">
<colgroup>
<col  />
<col  />
<col  />
<col  /></colgroup>
<thead>
<tr>
<th>#</th>
<th>Rule</th>
<th>Score</th>
<th>Reason</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4">
Overall Score: F (45)
</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>1</td>
<td>Make fewer HTTP requests</td>
<td>C</td>
<td>I had 13 external JS files, 5 external CSS files and 7 CSS background images</td>
</tr>
<tr class="odd">
<td>2</td>
<td>Use a CDN</td>
<td>F</td>
<td>Not using a CDN (Content Distribution Network), cause it is just not worth it in my case <img src='http://www.klauskomenda.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </td>
</tr>
<tr>
<td>3</td>
<td>Add an Expires header</td>
<td>F</td>
<td>No expires header set for CSS, JS and images</td>
</tr>
<tr class="odd">
<td>4</td>
<td>Gzip components</td>
<td>F</td>
<td>No gzipping of HTML, CSS, JS files</td>
</tr>
<tr>
<td>5</td>
<td>Put CSS at the top</td>
<td>F</td>
<td>CSS files were linked with the @import rule, which apparently made them finally load outside of the head</td>
</tr>
<tr class="odd">
<td>6</td>
<td>Put JS at the bottom</td>
<td>A</td>
<td>All JS gets loaded at the very bottom of the page, close to the closing body tag. <a href="http://javascript.crockford.com/code.html">Why?</a></td>
</tr>
<tr>
<td>7</td>
<td>Avoid CSS expressions</td>
<td>A</td>
<td>No CSS expressions used</td>
</tr>
<tr class="odd">
<td>8</td>
<td>Make JS and CSS external</td>
<td>n/a</td>
<td>Not necessary on this website</td>
</tr>
<tr>
<td>9</td>
<td>Reduce DNS lookups</td>
<td>A</td>
<td>Sources only provided by two sources (max.)</td>
</tr>
<tr class="odd">
<td>10</td>
<td>Minify JS</td>
<td>A</td>
<td>geolinkr.js file not minified</td>
</tr>
<tr>
<td>11</td>
<td>Avoid redirects</td>
<td>A</td>
<td>No redirects implemented</td>
</tr>
<tr class="odd">
<td>12</td>
<td>Remove duplicate scripts</td>
<td>A</td>
<td>No JavaScript file gets included twice in one page</td>
</tr>
<tr>
<td>13</td>
<td>Configure ETags</td>
<td>F</td>
<td>unconfigured on the Apache server</td>
</tr>
</tbody>
</table>
<p>As stated by <a href="http://www.codinghorror.com/blog/">Jeff Attwood</a>, <a href="http://www.codinghorror.com/blog/archives/000932.html">Yahoo!&#8217;s Problems Are Not Your Problems</a>, you need to be careful when following the guidelines for improving your YSlow scores. Some of them are only useful if you run a website with millions of unique visitors per day. If used wrongly, they can even slow down your site. So I took those results, tried to applied as much common sense to them and then tried to improve them using methods described in the following section.</p>
<h3>Taking action</h3>
<h4>1. Reducing HTTP Requests</h4>
<p>Even from a not-so-much technical and geeky perspective, this makes sense. If the browser needs to communicate with the server less often, this will make the web site load fast (&#8220;less talk, more action&#8221;). For me, I have chose two measures to achieve this:</p>
<h5>a. through Minification</h5>
<p>To reduce the number of HTTP requests for JS and CSS files, I decided to &#8220;minify&#8221; them into one file each. This not only reduces the number of HTTP requests, but also shrinks the filesize down by removing unnecessary whitespace, comments etc. The minified JavaScript file gets included as close as possible to the closing body tag, the CSS file gets called as soon as possible in the document. </p>
<h5>b. by creating CSS Sprites</h5>
<p>Of course I see the point in generating CSS Sprites which then contains all (or at least) many of the background-images you use on the site and then position them using CSS properties. I can certainly see the advantages of using a tool like <a href="http://spritegen.website-performance.org/">CSS Sprite Generator</a> (done by my co-workers <a href="http://www.ejeliot.com/">Ed</a> and <a href="http://muffinresearch.co.uk/">Stuart</a>) but I decided no to because of the following reasons:</p>
<ul>
<li>YSlow and Firebug are telling me that I am using 7 background images. I think that is not too bad.</li>
<li>My background images have mixed formats (JPG, GIF and PNG). Now I could make all of them PNGs and create a CSS Sprite. But I think it does not necessarily make sense, cause you use JPGs for certain images (pictures) and GIFs for images with greater areas of solid colours (e.g. comic illustrations). So mixing all of them into one does not make much sense to me.</li>
<li>Most likely, I am doing some little design changes here and there and I certainly don&#8217;t want to recreate my CSS Sprite every time.</li>
</ul>
<p>So I dropped that measure from my list, even though it might mean my score will not increase that much.</p>
<h4>2. Adding an Expires Header</h4>
<p>To ensure that elements are cacheable I configured Apache in a way that it sets an Expires header for 3 days in the future. This means that before those 3 days are over, the browser will always use the cached version of the image/CSS/JS/HTML file (if there is one). The requirement for this to work is that the <a href="http://httpd.apache.org/docs/2.0/mod/mod_expires.html">mod_expires module</a> is installed on your Apache webserver. You can check for that by doing a <span class="code">phpinfo()</span>. If that is not the case and you don&#8217;t have access to the httpd.conf file, you won&#8217;t be able to set the Expires Header through Apache. If you do have access to the httpd.conf file, add the following line to the LoadModule section and restart Apache.</p>
<pre>
<code>LoadModule expires_module modules/mod_expires.so</code>
</pre>
<p>Now that the module is available you can add the following lines to your .htaccess file:</p>
<pre>
<code>&lt;IfModule mod_expires.c&gt;
    # enable expirations
    ExpiresActive On

    # sets the Expires date 3 days out from the time of the request
    ExpiresDefault "access plus 3 days"
&lt;/IfModule&gt;</code>
</pre>
<p>Yahoo! recommends to set the Expires header to +10 years after the time of the request. This might be fine for Yahoo!, but this only seems to be wise if you are dead-serious that this file will never ever gonna change. Cause if you do change it on the server, it won&#8217;t force any change on the client side&#8230;the user agent will not even bother looking for a new version of that file if it is already in the cache. So unless you rename the file, it will never get picked up by the browser until 2017&#8230;I mean, unless you clear the cache, of course.</p>
<h4>3. Turning on Gzipping</h4>
<p>This can be done using the <a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html">mod_deflate module</a>, which got introduced in Apache with version 2.0. Again, check if that module is available using <span class="code">phpinfo()</span>. The following line in http.conf will load the module:</p>
<pre>
<code>LoadModule deflate_module modules/mod_deflate.so</code>
</pre>
<p>The following additions to your .htaccess file will gzip HTML, CSS and JavaScript files:</p>
<pre>
<code>&lt;IfModule mod_deflate.c&gt;
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/x-javascript
&lt;/IfModule&gt;</code>
</pre>
<h4>4. Putting CSS at the top of the document</h4>
<p>Due to the fact that I used one basic stylesheet and, from within that one, imported the other stylesheets using the @import rule, for some reason, YSlow tells me that those stylesheet are not located in the HEAD section anymore. Because of the fact that the CSS is now minified, there is now only one single request to the CSS file using: </p>
<pre>
<code>&lt;link rel="stylesheet" href="[path to minified CSS file]" type="text/css" /&gt;</code>
</pre>
<h4>5. Configuring ETags&#8230;maybe not</h4>
<p>As this website does not receive high traffic &#8211; and I therefore do not run a serverfarm &#8211; and based on Jeff Attwoods article, I decided not to configure ETags at all on the server side. If, for some reason, you would like to do it, you are free to do so by making another addition to your .htaccess file. The following turns off ETags altogether:</p>
<pre>
<code>FileETag none</code>
</pre>
<h3>Actions taken, measuring again&#8230;</h3>
<p>After incorporating these changes, I measured the performance again with the same tools mentioned above. The results are:</p>
<table class="datatable small" cellspacing="0">
<colgroup>
<col  />
<col />
<col /></colgroup>
<thead>
<tr>
<th>Area</th>
<th># requests</th>
<th>Datasize (in kB)</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3">Overall: 18 requests, 165kB</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>HTML</td>
<td>1</td>
<td>31</td>
</tr>
<tr class="odd">
<td>CSS</td>
<td>1</td>
<td>5</td>
</tr>
<tr>
<td>JavaScript</td>
<td>6</td>
<td>77</td>
</tr>
<tr class="odd">
<td>Images</td>
<td>10</td>
<td>52</td>
</tr>
</tbody>
</table>
<p>Here are the noteworthy changes that occured in the YSlow scores including comments as to which scores/rules got affected:</p>
<table  class="datatable" cellspacing="0">
<colgroup>
<col  />
<col  />
<col style="width:12%;"/>
<col style="width:12%;"/>
<col /></colgroup>
<thead>
<tr>
<th>#</th>
<th>Rule</th>
<th>Score (after)</th>
<th>Score (before)</th>
<th>Reason/Comments</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5">
Overall Score: B (82)
</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>1</td>
<td>Make fewer HTTP requests</td>
<td>B</td>
<td>C</td>
<td>Still 6 JS files and 7 background images</td>
</tr>
<tr class="odd">
<td>3</td>
<td>Add an Expires header</td>
<td>B</td>
<td>F</td>
<td>Expires header now set, except for external Yahoo! Maps API JavaScript</td>
</tr>
<tr>
<td>4</td>
<td>Gzip components</td>
<td>A</td>
<td>F</td>
<td>Now, all components are gzipped</td>
</tr>
<tr class="odd">
<td>5</td>
<td>Put CSS at the top</td>
<td>A</td>
<td>F</td>
<td>CSS gets now included using <span class="code">link</span> within the HEAD</td>
</tr>
<tr>
<td>10</td>
<td>Minify JS</td>
<td>A</td>
<td>A</td>
<td>All JavaScript files get minified</td>
</tr>
<tr class="odd">
<td>13</td>
<td>Configure ETags</td>
<td>F</td>
<td>F</td>
<td>Left unconfigured</td>
</tr>
</tbody>
</table>
<h3>Conclusion</h3>
<p>By following the Exceptional Performance Rules (well, rather treating them as guidelines and using them based on Web Development common sense applied to your site/project) I was able to improve the performance of this site as follows:</p>
<table class="datatable small" cellspacing="0">
<colgroup>
<col />
<col />
<col /></colgroup>
<thead>
<tr>
<th>Area</th>
<th>After</th>
<th>Before</th>
<th>Change</th>
</tr>
</thead>
<tbody>
<tr>
<td>HTTP Requests</td>
<td>18</td>
<td>29</td>
<td>-39%</td>
</tr>
<tr class="odd">
<td>Page size (in kB)</td>
<td>165</td>
<td>194</td>
<td>-15%</td>
</tr>
<tr>
<td>YSlow score</td>
<td>B (82)</td>
<td>F (45)</td>
<td>+37</td>
</tr>
</tbody>
</table>
<p>As you can see, the overall performance scores improved quite significantly. They could even be improved by further reducing the number of HTTP requests (using CSS Sprites) or trying to further minify CSS and JavaScript files. Generally, I feel that the Exceptional Performance Rules are excellent guidelines if you want to improve the performance of any particular site. As stated above, before blindly trying to follow these rules, one needs to verify how valid each of these rules is for the site he or she is working on. The rules were made with websites in mind who serve several million visitors a day &#8211; if you own one of those sites, then certainly follow these rules. If not (which is more likely), try to find out which of these rules really make sense in your case. </p>
<h3>Further resources</h3>
<ul>
<li><a href="http://codeclimber.net.nz/">Simone Chiaretta</a> was able to find out the weight applied to each YSlow rule in <a href="http://codeclimber.net.nz/archive/2007/08/15/Dissecting-YSlow.aspx">Dissecting YSlow</a></li>
<li><a href="http://www.codinghorror.com/blog/">Jeff Atwood</a> tells you why <a href="http://www.codinghorror.com/blog/archives/000932.html">Yahoo&#8217;s Problems Are Not Your Problems</a></li>
<li>Get <a href="http://developer.yahoo.com/yslow/">YSlow for Firebug</a></li>
<li><a href="http://developer.yahoo.com/performance/">Yahoo!&#8217;s Exceptional Performance Team</a></li>
<li>Douglas Crockford&#8217;s <a href="http://www.crockford.com/javascript/jsmin.html">JSMin</a></li>
<li><a href="http://developer.yahoo.com/yui/compressor/">YUI Compressor</a>, another JavaScript minifier</li>
<li><a href="http://csstidy.sourceforge.net/">CSS Tidy</a>, an opensource CSS parser and optimiser</li>
<li><a href="http://website-performance.org/">Website Performance</a> by <a href="http://www.ejeliot.com/">Ed</a> and <a href="http://muffinresearch.co.uk/">Stuart</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2007/11/10/boost-your-website-performance/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

