28. February 2012 01:10
The load time of websites is one of the most important factors affecting its usability; most Internet users will just skip a site altogether if it fails to load within a couple of seconds. Below you will find the summary of the “Speed Up Your Site” series. Those are simple yet effective ways to make sure that your website is running fast. You can click on each point to read the article with comments from the readers.
- Optimize Images: always use the “Save for the web” feature included on image editing software. Images represent the heavier load on virtually any website so make sure you are optimizing them. Alternatively you can also turn to an online image optimizer.
- Image Formats: apart from optimizing images it is important that you choose the right format. JPEG format is suitable for photographs or true-color images. The GIF format should be used with flat-color images like logos or buttons. PNG works very similar to GIF but it supports more colors.
- Optimize Your CSS: most websites are designed with CSS nowadays. Make sure to aggregate and clean your CSS. CleanCSS is an online tool that will merge similar selectors, remove useless properties and remove the whitespace from your code.
- Use a Slash on Your Links: when a user opens a link on the form “http://www.domain.com/about” the server will need to figure what kind of file or page is contained on that address. If you include a slash (/) at the end of the link the server will already know that this is a directory page, reducing the load time of the site.
- Use the Height and Width Tags: many people forget to add the Height and Width tags on image codes. Those tags will make sure that the browser knows the size of the image before loading it. The result is that it will reserve a spot for the images while loading the rest of the page, speeding up the whole process.
- Reduce the HTTP Requests: when opening a web page every object (images, scripts and the line) will require a round trip to the server. This latency can add several seconds to the load time of your site. Make sure to reduce the number of objects and to combine CSS files and scripts together.
Add an Expires or a Cache-Control Header:
There are two aspects rule: 1:For static components: implement "Never expire" policy by setting far future
Expires header. 2:For dynamic components: use an appropriate
Cache-Control header to help the browser with conditional requests.
The time it takes to transfer an HTTP request and response across the network can be significantly reduced by decisions made by front-end engineers. It's true that the end-user's bandwidth speed, Internet service provider, proximity to peering exchange points, etc. are beyond the control of the development team. But there are other variables that affect response times. Compression reduces response times by reducing the size of the HTTP response.
Starting with HTTP/1.1, web clients indicate support for compression with the Accept-Encoding header in the HTTP request.
Accept-Encoding: gzip, deflate
Put Stylesheets at the Top: While researching performance at Yahoo!, we discovered that moving stylesheets to the document HEAD makes pages appear to be loading faster. This is because putting stylesheets in the HEAD allows the page to render progressively.