<?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>Rick Huby dot com</title>
	<atom:link href="http://www.rickhuby.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rickhuby.com</link>
	<description>End to end web developer with a passion for user experience.</description>
	<lastBuildDate>Fri, 20 Jul 2012 19:59:37 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>MSDN Usability Advice Gaff</title>
		<link>http://www.rickhuby.com/2012/msdn-usability-advice-gaff/</link>
		<comments>http://www.rickhuby.com/2012/msdn-usability-advice-gaff/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 07:26:59 +0000</pubDate>
		<dc:creator>Rick Huby</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://www.rickhuby.com/?p=369</guid>
		<description><![CDATA[I got sent a link to an MSDN usability article with &#8220;20 Tips for a Better, Functional User Experience&#8221;. Number 9 on the list is &#8220;Never Disrupt the User&#8221; &#8211; which was amusingly accompanied by an invitation to take an online survey. It made me laugh so I thought I&#8217;d share it.]]></description>
			<content:encoded><![CDATA[<p>I got sent a link to an MSDN usability article with &#8220;20 Tips for a Better, Functional User Experience&#8221;.</p>
<p>Number 9 on the list is &#8220;Never Disrupt the User&#8221; &#8211; which was amusingly accompanied by an invitation to take an online survey.</p>
<p>It made me laugh so I thought I&#8217;d share it.<a href="http://www.rickhuby.com/wp-content/uploads/msdn-usability-advice.png"><img class="alignnone size-large wp-image-371" title="MSDN Usability Advice" src="http://www.rickhuby.com/wp-content/uploads/msdn-usability-advice-600x415.png" alt="MSDN Usability Advice" width="600" height="415" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rickhuby.com/2012/msdn-usability-advice-gaff/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Skills for Front End Developers</title>
		<link>http://www.rickhuby.com/2012/skills-for-front-end-developers/</link>
		<comments>http://www.rickhuby.com/2012/skills-for-front-end-developers/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 11:06:11 +0000</pubDate>
		<dc:creator>Rick Huby</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[front end dev]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[skill]]></category>

		<guid isPermaLink="false">http://www.rickhuby.com/?p=357</guid>
		<description><![CDATA[Louis Lazarus over at impressivewebs.com recently wote an interesting article on the skills which front end developers should have.  It was an interesting post though I felt it turned into a bit of a framework/buzzword list, so I thought I would put together my own thoughts on the matter. The main difference I think is [...]]]></description>
			<content:encoded><![CDATA[<p>Louis Lazarus over at impressivewebs.com recently wote an interesting <a href="http://www.impressivewebs.com/skills-front-end-developers/">article </a>on the skills which front end developers should have.  It was an interesting post though I felt it turned into a bit of a framework/buzzword list, so I thought I would put together my own thoughts on the matter. The main difference I think is that I&#8217;ve tried to categorise the skills somewhat and to give some more focus for a budding front end dev to review.</p>
<h2>Technical</h2>
<ul>
<li>HTML, XHTML and HTML 5</li>
<li>CSS2 and CSS 3</li>
<li>JavaScript</li>
<li>One of jQuery/MooTools/Scriptaculous or similar</li>
<li>Ajax</li>
<li>In browser debugging/tweaking</li>
</ul>
<h2>Conceptual</h2>
<ul>
<li>Basics of OOP</li>
<li>MVC</li>
<li>Performance considerations on the front end</li>
<li>Differing approaches to CSS</li>
<li>Grid systems and CSS frameworks</li>
<li>UX and usability</li>
<li>Design</li>
<li>Markup semantics</li>
</ul>
<h2>Useful side skills</h2>
<ul>
<li>Server side language/framework</li>
<li>CMS knowledge (WordPress, Drupal or Joomla perhaps)</li>
<li>Basics of SEO</li>
<li>Version control</li>
<li>Accessibility considerations</li>
<li>JSON</li>
<li>User testing</li>
</ul>
<p>I&#8217;m sure it&#8217;s not an exhaustive list but I think it may be more useful for someone looking to become a front end developer, than the original shopping list of skills.</p>
<p>That&#8217;s all my opinion though &#8211; be interested to hear from others on this!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rickhuby.com/2012/skills-for-front-end-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google, mobile payments &amp; biographical data</title>
		<link>http://www.rickhuby.com/2011/google-mobile-payments-biographical-data/</link>
		<comments>http://www.rickhuby.com/2011/google-mobile-payments-biographical-data/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 08:53:07 +0000</pubDate>
		<dc:creator>Rick Huby</dc:creator>
				<category><![CDATA[Opinion]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[social networking]]></category>

		<guid isPermaLink="false">http://www.rickhuby.com/?p=341</guid>
		<description><![CDATA[As a reader of Daily Reckoning I was interested in an article they put together on the rise (or more to the point, the lackthereof) of payments via mobile phones in the US. It mentions the lack of adoption of this technology in the US compared to many other places in the world. The crux [...]]]></description>
			<content:encoded><![CDATA[<p>As a reader of Daily Reckoning I was interested in an article they put together on the rise (or more to the point, the lackthereof) of payments via mobile phones in the US. It mentions the lack of adoption of this technology in the US compared to many other places in the world. The crux of the issue, according to the Daily Reckoning, is that the financial institutions do not want to let the Google’s of this world start muscling in on their oligopoly – driving down profits and taking market share from their bread and butter retail card payment profits (remember that every transaction made by credit or debit card costs the retailer).</p>
<p>This got me thinking about how it is yet another means by which Google can learn more about you. This will give them more data on where you go and what you buy. They may not be able to sell your email address to interested third parties, but they could certainly tailor the advertisements you see on the Internet. They already allow adverts to follow you round the Internet with Google Remarketing, it’s really just an extension of that. As I started thinking about all of this I started to think about the biographic data they can build up about a Google user.</p>
<h2>So what can Google learn about me?</h2>
<p>Off the top of my head I can identify the following that Google could figure out about you from its own data:</p>
<ul>
<li>What you search for on the Internet (search services)</li>
<li>What websites you visit (search services, analytics, your Google account, Chrome data?)</li>
<li>Who your friends are (Google+, Blogger)</li>
<li>What your interests are (email, Google+, Google Reader plus many more)</li>
<li>Who you are in contact with and what you talk about (Gmail, Google voice)</li>
<li>Where you go (maps, android based location services)</li>
<li>What products you would like to buy (product search, search services, Adwords tracking data)</li>
<li>What you buy (checkout, possibly their future payment systems)</li>
<li>Your financial interests (inferred by settings in Google Finance perhaps)</li>
</ul>
<p>Some of this may be hard to find out and to collate, but for the masters of search it would surely not be impossible.</p>
<p>A few examples</p>
<ol>
<li>You use your android mobile to pay for takeaways locally 3 times in 6 weeks. Google matches this data up and Pizza Hut pay to advertise to people in your area who have bought takeaway recently.</li>
<li>You follow several web design blogs in Google Reader, follow some well known developers in Google+ Circles, often search for WordPress related items via Google – Dreamhost pays to advertise in front of WordPress developers</li>
<li>You have a conversation via Gmail or Google chat and talk about your recent ankle injury. The adverts following you around the Internet are suddenly all about physiotherapists in your local area.</li>
</ol>
<p>For the tin foil hat wearing brigade I’ll also mention 23andme.com, a company part owned by Anne Wojcicki who is married to Google co-founder Sergey Brin. The company offers a service that enables you to get a genetic profile of yourself, highlighting which diseases and illnesses you are predisposed to. Google has reportedly invested around $6.5M in the service. Imagine signing up for that and then seeing lots of adverts for the miracle drugs to stop you getting such a disease. That would be an amazing opportunity for the pharmaceuticals industries.</p>
<h2>Closing</h2>
<p>I’m not advocating that everyone cancels all Google account and switches to other email providers or anything, nor am I suggesting that Google has abandoned its “Do no evil” motto, however it is worth considering the clout that this data will give Google in years to come.</p>
<p>I’d also suggest that it is not just Google to consider – Facebook and LinkedIn are building up similar profiles of your personal and business personas to help their advertisers target you. They will have a much easier time profiling you, though perhaps Google can get a larger overall view.</p>
<p>The Internet and World Wide Web have made the lives of the everyman more and more public and it is only to be expected that companies will try and use that information for their own gains.</p>
<h2>Sources</h2>
<ul>
<li><a title="Banking on your phone" href="http://dailyreckoning.com/banking-on-your-phone/">dailyreckoning.com/banking-on-your-phone/</a></li>
<li><a title="23andMe entry on Wikipedia" href="http://en.wikipedia.org/wiki/23andMe">en.wikipedia.org/wiki/23andMe</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rickhuby.com/2011/google-mobile-payments-biographical-data/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JavaScript: sort objects in array</title>
		<link>http://www.rickhuby.com/2011/javascript-sort-objects-in-array/</link>
		<comments>http://www.rickhuby.com/2011/javascript-sort-objects-in-array/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 20:38:26 +0000</pubDate>
		<dc:creator>Rick Huby</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.rickhuby.com/?p=227</guid>
		<description><![CDATA[I needed to sort an array of objects in JavaScript recently and was quite frankly amazed by 2 things: I&#8217;d never done it before in 7+ years of JavaScript It&#8217;s really rather easy! JavaScript has Array.sort that will order an array&#8217;s contents in ascending alphabetical order. So: var testArray = ['c', 'a', 'b']; testArray.sort(); //sorts [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to sort an array of objects in JavaScript recently and was quite frankly amazed by 2 things:</p>
<ol>
<li>I&#8217;d never done it before in 7+ years of JavaScript</li>
<li>It&#8217;s really rather easy!</li>
</ol>
<p>JavaScript has <code>Array.sort</code> that will order an array&#8217;s contents in ascending alphabetical order. So:</p>
<pre class="brush: javascript">
var testArray = ['c', 'a', 'b'];
testArray.sort();
//sorts as a, b, c
</pre>
<p>The default sort does not sort numeric data, it is purely a character based sort, so:</p>
<pre class="brush: javascript">
var testArray = [3, 1, 2, 19];
testArray.sort();
//sorts as 1, 19, 2, 3
</pre>
<p><code>Array.sort</code> takes a function as an optional parameter. The function takes two parameters which are the two elements in the array that you are comparing. The function needs to compare these two elements and figure out which should take precedence:</p>
<ul>
<li><strong>Less than 0</strong>: First item is before the second</li>
<li><strong>0</strong>: identical items</li>
<li><strong>More than 0</strong>: First item is after the second</li>
</ul>
<p>If we want to sort these items in a descending order then we need to pass a function to the <code>Array.sort</code> do something like the following:</p>
<pre class="brush: javascript">
function ascending(a, b){
	if (a === b) {
		return 0;
	} else if (b > a) {
		return 1;
	}
	return -1;
}

var testArray = ['c', 'a', 'b'];
testArray.sort(ascending);
//sorts as c, b, a

</pre>
<h2>Wasn&#8217;t this post about sorting arrays of objects?</h2>
<p>Sorry, I digress, but that was <code>Array.sort</code> 101. Below are a couple of simple ideas for sorting a simple object array &#8211; these could be replaced by whatever fancy pants sorting logic you need, but hopefully this will save someone, somewhere some faffing and Googling. </p>
<pre class="brush: javascript">

var arrayOfPeople = [
	{name:"Rick Huby", email:"rick@test.com", age:30},
	{name:"Alan Smith", email:"mrsmith@test.com", age:25},
	{name:"Jo Jenkins", email:"iamjo@test.com", age:40},
	{name:"Dave Smith", email:"dave@test.com", age: 35}
];

function orderByNameAscending(a, b) {
	if (a.name == b.name) {
		return 0;
	} else if (a.name > b.name) {
		return 1;
	}
	return -1;
}

function orderByEmailAscending(a, b) {
	if (a.email == b.email) {
		return 0;
	} else if (a.email > b.email) {
		return 1;
	}
	return -1;
}

function orderByAgeAscending(a, b) {
	return a.age - b.age;
}

arrayOfPeople.sort(orderByNameAscending);
arrayOfPeople.sort(orderByEmailAscending);
arrayOfPeople.sort(orderByAgeAscending);

</pre>
<p>If you want to progress these then I would at least put some defensive logic in to ensure that calling the object attributes (<code>a.name</code> etc.) doesn&#8217;t cause a runtime error (try/catch or some rudimentary <code>a.name === undefined</code> check may be enough).</p>
<ul class="labsDemo demoOnly floatedList">
<li class="floatedListItem"><a class="labsLink viewDemo" href="/labs/javascript-object-sort/">View Demo</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rickhuby.com/2011/javascript-sort-objects-in-array/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>8 Quick wins for improving page speed</title>
		<link>http://www.rickhuby.com/2011/quick-wins-for-improving-page-speed/</link>
		<comments>http://www.rickhuby.com/2011/quick-wins-for-improving-page-speed/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 19:42:24 +0000</pubDate>
		<dc:creator>Rick Huby</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Managing]]></category>
		<category><![CDATA[Google Page Speed]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[YSlow]]></category>

		<guid isPermaLink="false">http://www.rickhuby.com/?p=67</guid>
		<description><![CDATA[It&#8217;s been stated many times before that you only have a small window of opportunity to capture a user&#8217;s attention when they visit your website. One factor in grabbing this user and holding on to them is in ensuring the web page they land on loads quickly. Page download speed is also a factor in [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been stated many times before that you only have a small window of opportunity to capture a user&#8217;s attention when they visit your website. One factor in grabbing this user and holding on to them is in ensuring the web page they land on loads quickly.</p>
<p>Page download speed is also a factor in Google&#8217;s ranking algorithm, making performance even more important now, so ensuring good website performance is paramount.</p>
<p>Most websites can be improved with a few minor tweaks and changes. To this end I&#8217;ve compiled a small list of quick fixes to improve your website&#8217;s performance.</p>
<p>To help with testing your website I would recommend using Firefox and installing the YSlow and Google Page Speed tools.</p>
<h2>List of website performance improvements</h2>
<ol class="scrollTo">
<li><a href="#postAnchor1">Combine CSS and JavaScript files</a></li>
<li><a href="#postAnchor2">Minify HTML page and CSS and JavaScript files</a></li>
<li><a href="#postAnchor3">GZip/Deflate plain text files</a></li>
<li><a href="#postAnchor4">Ensure Javascript is at the bottom of the page</a></li>
<li><a href="#postAnchor5">Remove inline CSS and JavaScript</a></li>
<li><a href="#postAnchor6">Minimise external lookups (DNS)</a></li>
<li><a href="#postAnchor7">Reduce image sizes (without reducing image quality)</a></li>
<li><a href="#postAnchor8">Use image sprites where possible</a></li>
</ol>
<h2 id="postAnchor1">1. Combine CSS and JavaScript files</h2>
<h3>What&#8217;s the issue?</h3>
<p>Every file the user downloads comes with a performance overhead – each one has to be looked up which takes time, plus if you have cookies on your website, they all have to be sent along with each file request.</p>
<h3>How do I improve this?</h3>
<p>Most CSS files can be combined into one master CSS document, as can most JavaScript files.</p>
<p>This can be done manually by copying and pasting the contents of your CSS or Javascript files into one master file for each (master.css, master.js).</p>
<p>You may prefer to keep some files separate for ease of long term maintenance. If so, you can install tools such as minify (PHP), Combres (.NET) or JAWR (Java) which can be configured to automatically combine your resources from multiple sources. Alternatively you can build deploy scripts that combine the resources as part of a deployment process.</p>
<p><a href="#top">Back to top</a></p>
<h2 id="postAnchor2">2. Minify HTML page and CSS and JavaScript files</h2>
<h3>What&#8217;s the issue?</h3>
<p>HTML, Javascipt and CSS files written by hand will include a lot of white space to ensure they are both readable and maintable by humans.</p>
<p>Most white space is unnecessary for computers to interpret the code.</p>
<p>As such all the white space in these files is redundant and just adds to the size of the file being downloaded.</p>
<h3>How do I improve this?</h3>
<p>The previously mentioned Minify tool does have a facility for minifying the HTML page, as well as CSS and JavaScript files prior to output. This is only available for PHP.</p>
<p>For minifying CSS and JavaScript files on the .NET platform you can use Combres. There is also a port of the YUI Compressor library. Java has the JAWR tool which is very similar to Combres.</p>
<p><a href="#top">Back to top</a></p>
<h2 id="postAnchor3">3. Compress plain text files for download</h2>
<h3>What&#8217;s the issue?</h3>
<p>By default, HTML, JavaScript and CSS files are uncompressed. The pure text that is written is what is downloaded.</p>
<p>Plain text can however be compressed by about 70% of its original size and then uncompressed on the browser side.</p>
<h3>How do I improve this?</h3>
<p>There are two common ways of compressing this content: <strong>GZip</strong> and <strong>Deflate</strong>.</p>
<p>Both do essentially the same job. In the examples I have restricted the compression to only text based files, as running compression on items which are already compressed (typically video, music and images) is a waste of time and server resource.</p>
<h4>Deflate in Apache</h4>
<p>Assuming that <code>mod_deflate</code> is enabled, add the following line to your <code>.htaccess</code> file or in the httpd.conf.</p>
<pre class="brush: php; gutter: false">
AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript application/x-javascript text/xml
</pre>
<p>If <code>mod_deflate</code> is not enabled and you have root access to your server you can try this resource: <a href="http://www.howtoforge.com/apache2_mod_deflate">http://www.howtoforge.com/apache2_mod_deflate</a></p>
<h4>GZip in Apache</h4>
<p>For an authoritative look at GZip in Apache I&#8217;d recommend Uncle Google as I&#8217;ve never looked at this on Apache, however from reading around the subject I believe that Deflate is marginally quicker.</p>
<h4>GZip/Deflate in IIS</h4>
<p>If you use combres (mentioned in point 1) this can deal with the compression of CSS and JavaScript files for you.</p>
<p>If you want to manually deal with this then you are going to need to change some IIS config files. The Small Workarounds website has a good article on <a href="http://www.smallworkarounds.net/2009/01/aspnet-iis-tricks-using-gzip.html">GZip in IIS</a>.</p>
<p>Many minification tools such as Minify, Combres and JAWR can be configured to GZIP the contents themselves instead of getting the server to do it.</p>
<p><a href="#top">Back to top</a></p>
<h2 id="postAnchor4">4. Ensure Javascript is at the bottom of the page</h2>
<h3>What&#8217;s the issue?</h3>
<p>Browser&#8217;s request more than one file at a time, by the HTTP 1.1 specification 2 at a time per hostname. You can potentially speed up your page load by splitting images, CSS and other resources across multiple domains (e.g. request images from images.example.com and css from files.example.com but the page from www.example.com).</p>
<p>However, when JavaScript files are downloading, nothing else is brought down in parallel (even on different hostnames).</p>
<h3>How do I improve this?</h3>
<p>Simply putting all your JavaScript requests at the bottom of the HTML document, directly before the closing <code>&lt;body&gt;</code> tag will minimise the impact as you can load all of your content in advance of the Javascript functionality.</p>
<p>Some scripts may need to be loaded earlier, but this will need to be a judgement call on the part of the developer.</p>
<p><a href="#top">Back to top</a></p>
<h2 id="postAnchor5">5. Remove inline CSS and JavaScript</h2>
<h3>What&#8217;s the issue?</h3>
<p>CSS and JavaScript can be embedded within the actual HTML page (as opposed to being linked to an external file).</p>
<p>This bloats the HTML page size and reduces the browsers&#8217; ability to cache common style and script information, as the CSS and JavaScript will be downloaded for each page request. Using external files allows the browser to just download the information once and reuse for every page request that needs it.</p>
<h3>How do I improve this?</h3>
<p>Simply ensure that all JavaScript and CSS content is stored within external files.</p>
<p>Ensure you check any third party libraries and widgets which you may include in your page as these often have inline CSS and JavaScript snippets to be included in the page. These can normally be refactored into external files with a little CSS and JavaScript knowledge.</p>
<p><a href="#top">Back to top</a></p>
<h2 id="postAnchor6">6. Minimise external lookups (DNS)</h2>
<h3>What&#8217;s the issue?</h3>
<p>There is a time overhead in looking up DNS entries which can add significantly to the page speed. Every new hostname encountered requires a lookup to an IP address, according to Yahoo! this adds 20-120 milliseconds per hostname to the page load.</p>
<h3>How do I improve this?</h3>
<p>Simply reducing the number of domains that are referenced for page resources (images, CSS, javascript etc) will improve your score on this. However there is a caveat on this because sometimes using multiple domains allows for improved performance as each domain will increase the number of parallel downloads your page can make.</p>
<p>On the one hand referencing files from different domains allows the browser to download more files concurrently, however each domain that needs to be looked up will add an overhead. It really is a balancing act that should be reviewed for each project.</p>
<p>An additional topic to be considered is Content Delivery Networks (also known as CDN&#8217;s), but that&#8217;s probably for another post.</p>
<p><a href="#top">Back to top</a></p>
<h2 id="postAnchor7">7. Reduce image file size (without reducing quality)</h2>
<h3>What&#8217;s the issue?</h3>
<p>Some image formats, especially PNG retain a lot of information that is not required for the image rendering itself.</p>
<p>This data can be removed, leaving the image file smaller but the image exactly the same as it was (also known as lossless compression).</p>
<h3>How do I improve this?</h3>
<p>YSlow itself comes with a handy link to the Smush.It! website where you can compress your images in this lossless fashion.</p>
<p>There are also tools for doing this on your local machine, some of which you can configure as part of a deployment script.</p>
<ul>
<li><a href="http://www.imagemagick.org/script/convert.php">ImageMagick command line tools</a></li>
</ul>
<p>For WordPress, Joomla and Drupal websites there are also plugins which can be installed to do this for all uploaded images.</p>
<ul>
<li><a href="http://wordpress.org/extend/plugins/wp-smushit/">WP Smush.it plugin for WordPress</a></li>
<li><a href="http://extensions.joomla.org/extensions/site-management/content-networking/14395">jomCDN for Joomla</a></li>
<li><a href="http://drupal.org/project/imagecache_smushit">Imagecache smush.it for Drupal</a></li>
<li><a href="http://drupal.org/project/imageapi_optimize">ImageAPI Optimise for Drupal</a></li>
<li><a href="http://drupal.org/project/cdn">CDN for Drupal</a></li>
</ul>
<p><a href="#top">Back to top</a></p>
<h2 id="postAnchor8">8. Use image sprites where possible</h2>
<h3>What&#8217;s the issue?</h3>
<p>As mentioned previously, every file request comes with a performance overhead which adds up to a slower web page. Most pages are made up of many images which means there can be a significant overhead in requests. Cookies are sent along with every single request, so for any website with lots of cookies and lots of images you can quickly add a lot of data to each page load.</p>
<p>Sprites are derived from computer game animation, one image file contains all the individual frames for an animation. A visible area displays part of the overall image and the image is moved to create the animation effect.</p>
<p>In web terms we are less concerned with the animation (though this technique is used for some animations) as we are with reducing multiple images into one request.</p>
<h3>How do I improve this?</h3>
<p>CSS allows us to use background images, in many cases these background images can be combined and displayed in ways that only show a small portion of the overall image.</p>
<p>By reducing a pages image requests down to 1 or 2 requests you will speed up the performance.</p>
<div id="attachment_119" class="wp-caption alignnone" style="width: 600px"><img class="size-full wp-image-119" title="sprite-montage" src="/wp-content/uploads/sprite-montage.jpg" alt="Montage of sprited elements from travelsupermarket.com" width="600" height="273" /><p class="wp-caption-text">Montage of sprited elements from travelsupermarket.com, all taken from one sprited image.</p></div>
<p>This example of a sprite reduced the number of requests from 36 to 2 requests and improved performance significantly.</p>
<p>You may ask why this was reduced to 2 requests and not 1. This is because there is a second image file that is used on the website – a 1px square transparent gif. This is used in a number of places as an HTML image, the sprite is then used as a background image on the transparent gif.</p>
<h4>Example CSS definitions</h4>
<pre class="brush: css; gutter: false">
.sprite {
	background: url('sprite.png') no-repeat;
}

.someItem {
	background-position: 0 -100px;
}

.someOtherItem {
	background-position: -50px -200px;
}
</pre>
<h4>Example HTML usage</h4>
<pre class="brush: html; gutter: false">
<div class="sprite someItem"></div>

<img src="blank.gif" class="sprite someOtherItem" />
</pre>
<p>Using this method we could technically reduce an entire websites image content down to 2 image requests (the sprite and the transparent gif). In practise this is not realistic as maintenance and overall file size of the sprite would eventually render it impractical, but if you always think in terms of sprites you can probably reduce a large number of requests.</p>
<p>My personal practise is to group things into ‘sprite groups&#8217;, for example all the buttons in one sprite, the navigation in another, one for icons and so on. I would also recommend keeping a Photoshop (or similar) file for each sprite as it will make maintenance much easier in the future.</p>
<p><a href="#top">Back to top</a></p>
<h2>In Summary</h2>
<p>There are further things that can also be done, but in experience these items tend to be easy to achieve and have a major improvement on the performance of the page.</p>
<p>There are other improvements that can be made, though some require a little more work than most of the suggestions here. If you want to read around the subject then the following subjects may be of interest:</p>
<ul>
<li>Use of multiple domains</li>
<li>CDN/Content Delivery Networks</li>
<li>Caching strategies for your website</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rickhuby.com/2011/quick-wins-for-improving-page-speed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Spiderable Select Field</title>
		<link>http://www.rickhuby.com/2011/jquery-spiderable-select-field/</link>
		<comments>http://www.rickhuby.com/2011/jquery-spiderable-select-field/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 19:40:47 +0000</pubDate>
		<dc:creator>Rick Huby</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Promoting]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.rickhuby.com/?p=64</guid>
		<description><![CDATA[There is always a lovely balance to be had between the worlds of design and code, especially when it comes to balancing the wants and desires of the product owner, especially when factoring in search engine optimisation (SEO). A recent project had a large SEO requirement which included the (mostly automated) optimisation of many thousands [...]]]></description>
			<content:encoded><![CDATA[<p>There is always a lovely balance to be had between the worlds of design and code, especially when it comes to balancing the wants and desires of the product owner, <strong>especially</strong> when factoring in search engine optimisation (SEO).</p>
<p>A recent project had a large SEO requirement which included the (mostly automated) optimisation of many thousands of pages across a vast number of brands and products. One of the key entry places for these optimised pages was however designed as a <code>select</code> field. Since search engine spiders don&#8217;t traverse forms this was obviously an issue so I devised a jQuery plugin to work round this issue.</p>
<ul class="labsDemo floatedList">
<li class="floatedListItem"><a href="https://github.com/rickhuby/jQuery-Spider-Select" class="labsLink getSource">Get Source</a></li>
<li class="floatedListItem"><a href="/labs/spider-select/" class="labsLink viewDemo">View Demo</a></li>
</ul>
<h2>Presenting jQuery Spider Select</h2>
<p>Since the main requirement was a huge traversible list of brands I decided to start with just that (in the following examples I have used individual websites, but the original one was a list of web pages on one particular website).</p>
<h3>Without JavaScript enabled (and what the search engine should see)</h3>
<ul>
<li><a href="http://www.bbc.co.uk/">BBC website</a></li>
<li><a href="http://www.rickhuby.com/">Rick Huby</a></li>
<li><a href="http://slashdot.org/">Slashdot</a></li>
<li><a href="http://www.amazon.co.uk/">Amazon UK</a></li>
</ul>
<h3>What the regular user will see</h3>
<p>The jQuery plugin simply runs through the <code>ul</code> and generates a list of URLs and link texts, then rebuilds these as a <code>select</code> field. Depending on the parameters passed the user will either just select a page and be taken there, or will click a button to navigate to the selected page.</p>
<p><img class="alignnone size-full wp-image-253" title="jQuery Spider Select Examples" src="http://www.rickhuby.com/wp-content/uploads/spider-select.gif" alt="jQuery Spider Select Examples" width="600" height="120" /></p>
<ul class="labsDemo floatedList">
<li class="floatedListItem"><a href="https://github.com/rickhuby/jQuery-Spider-Select" class="labsLink getSource">Get Source</a></li>
<li class="floatedListItem"><a href="/labs/spider-select/" class="labsLink viewDemo">View Demo</a></li>
</ul>
<h2>How to use jQuery Spider Select</h2>
<h3>HTML</h3>
<pre class="brush: html">&lt;ul id="whateverId"&gt;
	&lt;li&gt;&lt;a href="http://www.bbc.co.uk/"&gt;BBC website&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://www.rickhuby.com/"&gt;Rick Huby&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://slashdot.org/"&gt;Slashdot&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://www.amazon.co.uk/"&gt;Amazon UK&lt;/a&gt;&lt;/li&gt;			
&lt;/ul&gt;
</pre>
<h3>JavaScript</h3>
<pre class="brush: javascript">jQuery(document).ready(function(){

	$('#whateverId').spiderSelect();

});
</pre>
<h3>Options</h3>
<table>
<thead>
<tr>
<th>Item</th>
<th>Default</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td>defaultText</td>
<td>Please select</td>
<td>Any text based content</td>
</tr>
<tr>
<td>id</td>
<td>spiderSelect</td>
<td>Any valid id string</td>
</tr>
<tr>
<td>classes</td>
<td>Empty</td>
<td>List of space separated classes</td>
</tr>
<tr>
<td>trigger</td>
<td>button</td>
<td>button or select</td>
</tr>
<tr>
<td>buttonId</td>
<td>spiderSelectButton</td>
<td>Any valid id string</td>
</tr>
<tr>
<td>buttonText</td>
<td>Go</td>
<td>Any text based content</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.rickhuby.com/2011/jquery-spiderable-select-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting MySQL timestamp to RSS pubDate in PHP</title>
		<link>http://www.rickhuby.com/2011/converting-mysql-timestamp-to-rss-pubdate-in-php/</link>
		<comments>http://www.rickhuby.com/2011/converting-mysql-timestamp-to-rss-pubdate-in-php/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 20:02:47 +0000</pubDate>
		<dc:creator>Rick Huby</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RSS]]></category>

		<guid isPermaLink="false">http://www.rickhuby.com/?p=9</guid>
		<description><![CDATA[A quick and simple means of using PHP to convert a MySQL timestamp field into the required format for the RSS pubDate field. date('D, d M Y H:i:s O', strtotime($mysql_timestamp_val));]]></description>
			<content:encoded><![CDATA[<p>A quick and simple means of using PHP to convert a MySQL timestamp field into the required format for the RSS pubDate field.</p>
<pre class="brush: php; gutter: false">
date('D, d M Y H:i:s O', strtotime($mysql_timestamp_val));
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rickhuby.com/2011/converting-mysql-timestamp-to-rss-pubdate-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>XHTML, JavaScript &amp; CDATA</title>
		<link>http://www.rickhuby.com/2011/xhtml-javascript-cdata/</link>
		<comments>http://www.rickhuby.com/2011/xhtml-javascript-cdata/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 20:00:36 +0000</pubDate>
		<dc:creator>Rick Huby</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.rickhuby.com/?p=5</guid>
		<description><![CDATA[This is one of those really annoying pieces of syntax that I can never remember and that I always have to look up so I figured that other people would surely have the same issue :) Anyway, see below for how to write CDATA comments in your JavaScript to make it XHTML compliant.]]></description>
			<content:encoded><![CDATA[<p>This is one of those really annoying pieces of syntax that I can never remember and that I always have to look up so I figured that other people would surely have the same issue :)</p>
<p>Anyway, see below for how to write CDATA comments in your JavaScript to make it XHTML compliant.</p>
<pre class="brush: javascript;">
<script type="text/javascript">
//<![CDATA[
function foo() {
    alert('bar');
}
//]]&gt;
</script>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rickhuby.com/2011/xhtml-javascript-cdata/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery stop animation</title>
		<link>http://www.rickhuby.com/2010/jquery-stop-animation/</link>
		<comments>http://www.rickhuby.com/2010/jquery-stop-animation/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 19:38:17 +0000</pubDate>
		<dc:creator>Rick Huby</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.rickhuby.com/?p=59</guid>
		<description><![CDATA[On a recent project I was required to write some QUnit based tests for some jQuery widgets that I&#8217;d built. The goal was to try and test all of the functionality of the widget in isolation, however some aspects of the widget required animations to fire and complete before I could test the outcome. QUnit [...]]]></description>
			<content:encoded><![CDATA[<p>On a recent project I was required to write some QUnit based tests for some jQuery widgets that I&#8217;d built.  The goal was to try and test all of the functionality of the widget in isolation, however some aspects of the widget required animations to fire and complete before I could test the outcome.</p>
<p>QUnit was testing for the position of elements at the end of the animation, however as jQuery animations are done asynchronously (using setTimeout and/or setInterval I believe) the tests were failing as the animations were still in progress.</p>
<p>To resolve the issue we need to make jQuery stop animation in progress before making any assertions.  To do this simply trigger the animation, followed by using the jQuery <code>.stop()</code> function to cause all animations to complete immediately, before verifying the test conditions.</p>
<pre class="brush: javascript">
var $itemToAnimate = $("#item-to-animate");
$itemToAnimate.someAnimationCall();  //.slideDown, .animate etc.
$itemToAnimate.stop(true, true);

//some test condition here
</pre>
<p>The 2 arguments passed to stop clear all queued animations and make any active animations complete immediately.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rickhuby.com/2010/jquery-stop-animation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery input text selection toggler</title>
		<link>http://www.rickhuby.com/2010/jquery-input-text-selection-toggler/</link>
		<comments>http://www.rickhuby.com/2010/jquery-input-text-selection-toggler/#comments</comments>
		<pubDate>Fri, 12 Nov 2010 20:07:29 +0000</pubDate>
		<dc:creator>Rick Huby</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[UX]]></category>

		<guid isPermaLink="false">http://www.rickhuby.com/?p=18</guid>
		<description><![CDATA[On a recent project I was asked to add some client side functionality to an input field, so that people clicking in the input box would have the contents auto-selected. Not a problem, a fairly easy piece of work, especially with jQuery . This evolved into additional functionality to improve the usability of the input [...]]]></description>
			<content:encoded><![CDATA[<p>On a recent project I was asked to add some client side functionality to an input field, so that people clicking in the input box would have the contents auto-selected. Not a problem, a fairly easy piece of work, especially with jQuery .</p>
<p>This evolved into additional functionality to improve the usability of the input box though, so that if the content was already selected then the cursor was just placed where the user clicked (so that someone could edit the content rather than having to retype it). Then I was asked to allow the user to create a selection of the content and allow that to remain selected, rather than forcing the full text to be selected. I love working on Agile projects :)</p>
<p>I quite liked the functionality though, so I’ve reworked this into a jQuery plugin to provide the same functionality.</p>
<h2>Requirements in summary:</h2>
<p>  1. Clicking in the input box with content in auto-selects all content.<br />
  2. If the user selects a number of characters then only those selected characters are left selected<br />
  3. If there is already selection made in the input box and the user clicks in the box, all highlighting is removed.</p>
<ul class="labsDemo floatedList">
<li class="floatedListItem"><a class="labsLink getSource" href="https://github.com/rickhuby/jQuery-input-text-selection-toggler">Get Source</a></li>
<li class="floatedListItem"><a class="labsLink viewDemo" href="/labs/jquery-input-selection-toggler/">View Demo</a></li>
</ul>
<h2>Some basic HTML&#8230;</h2>
<pre class="brush: html">
<div id="demo-holder">

   <form action="#" method="post">
        
       <input type="text" name="demo-selector" id="demo-selector" value="Example text" />
    
   </form>

</div>
</pre>
<h2>&#8230;and the jQuery plugin&#8230;</h2>
<pre class="brush: javascript">
(function( $ ){

	$.fn.textSelectionToggler = function() {
	
		var jqInput = $(this);
		var domInput = jqInput.get(0);
		jqInput.data('selected', false);
	
		this.mouseup(function(){                       

			if (shouldSelectAllTextInField()) {
				jqInput.select();
			}
			
			toggleSelectedFlag();
		});
	   
		this.blur(function(){	
			clearSelectionAndResetSelectedFlag();
		});
		
		/** Text selection methods **/
		function shouldSelectAllTextInField() {
			if (!textSelectionAlreadyPresent() &#038;&#038; !specificTextRangeSelected()) {
				return true;
			}
			return false;
		}
		
		function textSelectionAlreadyPresent() {
			return jqInput.data('selected');
		}
		
		function specificTextRangeSelected() {
			if (isIE()) {
				return hasSelectionBeenMadeInIE();
			}
			return hasSelectionBeenMadeInGoodBrowser();			
		}
		
		function hasSelectionBeenMadeInIE() {
			domInput.focus();
			if (document.selection.createRange().text.length > 0) {
				return true;
			}
			return false;
		}
		
		function hasSelectionBeenMadeInGoodBrowser() {
			var selectionLength = domInput.selectionEnd - domInput.selectionStart;
			if (selectionLength > 0) {
				return true;
			}
			return false;		
		}
		
		/** Helper functions **/
		function toggleSelectedFlag() {
			if (jqInput.data('selected')) {
				jqInput.data('selected', false);
			}
			else {
				jqInput.data('selected', true);
			}
		}
		
		function isIE() {
			if (document.selection) {
				return true;
			}
			return false;
		}
		
		function isFF() {
			return ($.browser.mozilla);
		}
		
		function clearSelectionAndResetSelectedFlag() {
			if (isFF()) {
				//Fixes bug where FF selects then deselects the content after leaving and 
				//re-entering the field (if you click where the selected content was).
				var input = jqInput.get(0);
				input.selectionStart = 0;
				input.selectionEnd = 0;
			}
			
			jqInput.data('selected', false);
		}

	};
	
})( jQuery );
</pre>
<h2>&#8230;and to setup the functionality&#8230;</h2>
<pre class="brush: javascript">
$(document).ready(function() {           
   $("#demo-selector").inputSelector();
});
</pre>
<p><strong>Note:</strong> I have been experimenting with different styles of JavaScript, so if you think the above may be a little long winded you may be right &#8211; it could easily be re-written in 45 lines of code or less because that is what I started with before refactoring into small functions (not yet convinced this is a better method of writing code but the experiment goes on :)). </p>
<ul class="labsDemo floatedList">
<li class="floatedListItem"><a class="labsLink getSource" href="https://github.com/rickhuby/jQuery-input-text-selection-toggler">Get Source</a></li>
<li class="floatedListItem"><a class="labsLink viewDemo" href="/labs/jquery-input-selection-toggler/">View Demo</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rickhuby.com/2010/jquery-input-text-selection-toggler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: www.rickhuby.com @ 2013-05-24 16:58:05 -->