How to build faster loading websites

Coding considerations

How you code can make a big difference to site speeds. Although some developers advocate whitespace removal, that's only really useful for high traffic sites, and even then speed differences are typically negligible. But smaller modifications to code can actually make a bigger difference.

MySQL tuner

DATA MANAGEMENT: Check your SQL database for possible problems and speed up access to your content

Clearleft developer Natalie Downe suggests "using different servers for images or static files, so that you're increasing the number of concurrent connections that you can have". Alternatively, you can use content on the same server, but work with a few sub-domains, which the browser sees as separate servers.

Another in-vogue tip is the use of gzipping to reduce the size of HTTP responses. Rather than a server sending standard documents, they're sent compressed and then unpacked in the browser. This can hugely increase speed when it comes to text files, which compress well, with the trade-off being more processing power required by the server and some old and creaky browsers not supporting gzip.

Downe adds that, with care, you can make the compression even more effective: "If you're consistent in ordering CSS properties and HTML attributes – be that alphabetically or by some other method – this helps the gzip algorithm and reduces sizes further." (Note that you need to configure your server so it returns gzipped content if a browser can deal with it – is.gd/TTaS provides an overview of how to do so.)

External factors

It's also essential to think outside of the box to find further means of speeding up your site. Often, you might have blazing code and highly optimised content, but a site that's slow due to being held back by sluggish external content, such as adverts. If that's the case, weigh up advertising revenue versus major performance issues.

You should also check your host's site on a semi-regular basis. McLellan recalls how last year he investigated what his hosting company was offering for new accounts. "Technology is always getting cheaper and better, and we found the hosting account we were paying for was more expensive and not as good as the current new accounts being offered by the same company. So we made sure we were getting the most out of our limited budget by asking to be swapped to a new account. It saved us money and doubled the performance of our server in one simple move."

Finally, explore online resources for more information about site optimization – although be wary. Modera CEO Siim Vips explains: "There are optimisation tests online, but many are neither reliable nor trustworthy, since they're built to generate leads for developers." He suggests restricting yourself to freely available resources, including the well-known W3C validation services, along with "guidance and instructions from trusted and respected founders of principles that have set the standards that are still used today."

Two internet giants have made the greatest strides in this area. As Heilmann notes, "Yahoo and Google have both done a lot of research on web performance and released their findings." The Yahoo approach is particularly interesting – along with information organised into categories (images, CSS, mobile, and so on) at developer.yahoo.com/performance/, there's Firefox extension YSlow.

"Using YSlow, you can analyse a web page and you get rated A to F for each optimisation technique. You can click on each mark to learn what you can do to get a better score," says Heilmann. "Using tools such as these, you can easily optimise a site without being an expert – and they're great for showing just how much impact a few changes can have."