
Website Speed Optimization – Need Of The Hour
- June 25, 2015
- Leave a comment
One of the most frequently discussed issue in WordPress community is website speed optimization. Nowadays, it becomes a major concern for every website owner as traffic generation is associated with it. No one is ready to take the risk of losing even a single website visitor so, the need of the hour is that you need to optimize your website from both ends – Server side as well as Assets (JS, CSS, Images) side.
Optimization – Server-Side
Compression with Gzip:
Server side compression greatly reduces the time needed to process the request from client side, and Gzip is one of the best way to compress the resources sent by the server. For this purpose, use “mod_zip” with Apache 1.3 and “mod_deflate” with Apache 2.x. To enable Gzip compress using nginx server, you can use the following in the nginx configuration:
1 2 3 4 5 6 7 8 9 |
bc. gzip on; gzip_http_version 1.0; gzip_vary on; gzip_comp_level 6; gzip_proxied any; gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; # make sure gzip does not lose large gzipped js or css files # see http://blog.leetsoft.com/2007/7/25/nginx-gzip-ssl gzip_buffers 16 8k; |
Minimize Redirects:
Webmaster often do URL Redirects using JavaScript or meta, sometimes just to point user from an old page to new page or to point user to the correct destination. Additional HTTP request is generated with each redirect. More redirects are there, the slower user reach to the desired destination.
Reduce DNS Lookups:
It takes around 20-120 milliseconds to resolve any hostname to its IP address, and browser is locked down until the process is completed.
It is recommended that there should be no more than 2-4 hostnames, that would reduce the DNS lookup time. Hence, web performance could be increased.
Optimization – The Assets (CSS, JavaScripts, Images)
Merge Multiple JavaScript into one:
Each JavaScript file is requested using a separate HTTP Request, which means the more JavaScript files, more will be the HTTP Requests. This can be reduced be reducing the number of files that are included on the webpage. This can be achieved by combining multiple JavaScript files into a single file. It will drastically reduce the HTTP requests which will ultimately decrease the site load time.
Compress JavaScript and CSS:
Compression of JavaScript and CSS files refers to the compression of content, mean removal of white spaces and comments which will reduce the file sizes and will be downloaded earlier resulting in decrease in site load time.
Customize Header Expiry/Caching:
By adding the expiry header for the files like images and static JavaScript and CSS files will skip the additional HTTP requests when the browser will load the page for second time, as they are already cached within the browser itself.
Handling Web Images:
Images are vital part of a webpage. If these images are not properly optimized in terms of filesize, it will consume a hell lot of bandwidth which will reduce results and will increase the site load time. There are certain recommendations which should be kept in mind while development and optimizing the website:
- Use the right image extension (.jpg, .png, .gif etc) for different images. For example:
If there are a lot of colors in the image; you should use JPEG format as you can adjust the compression level in your image editor. But if you require image background to be transparent and add some opacity to it, then you should use PNG images - Always use height and width for images while adding it to a webpage
- Do not scale images
User Comments