How to decrease loading time of a webpage?
This question mostly arise when we have completed a project and now not our clients but we the development team feels that web pages are taking much time in loading although problems can be our internet speed or sometimes hosting performance issue. It is rarely considered if ever development team took notice of client’s complaint regarding loading time of the website because a new born baby website rarely get traffic overnight after development. So to satisfy ourselves regarding decreasing loading time of a web page we have the following options:
Compare the loading time of landing page, home page and other identical web pages
Calculate loading time of all the website through a software of any free service available online
- Now check that which files are being included uselessly all over the website pages?
Solution: Use if conditions and load only necessary files even scripts, images and styles.
- Do a little work on image manipulation and manage their sizes exactly which is required and compress them as well. It is not a wise act to consume much of bandwidth. Try to provide an efficient solution if you are not working on any Art/Graphics related website.
- Try to cache queries, if you are working in CI else try to reduce unions, joins, sub-queries and queries in view/foreach body etc.
- Cache images, styles, scripts according to their change frequency if project is underdevelopment/maintenance, but you can cache a no. of files forever e.g. jquery, json, swfobject, facebook relates files, prototype library files. Because these are required but you are not supposed to change in these files at all at least on intermediate level of development.
- Make sure that you are linking script files, style sheets and not including them as a PHP or any other script files which is being rendered on html page line by line and taking much time every time.
- Try to reduce CRUD operations on page load, if you feel that traffic is increasing rapidly and you need to log something so calculate the frequency of changes and write on disk with files. Then perform CRUD operations on those files instead of involving database transaction every-time.
- Now try to use .htaccess caching, which will finally do magic for you.
- Prefer to use iframes for advertisement which are either js script related or youtube players etc.
- Follow these steps in reverse manner to get a different result, sequence matters according to the situation.
Link: WP SpeedUp
Last updated: August 23, 2015
Video Tutorial: Click here to watch