This is probably the most common case for a website being slow. There are many helpful tools for investigating this problem. We recommend this web page analyzer and Firefox’s addon called YSlow.
Here is what it includes:
- Slow / heavy MySQL database queries – such are known to be generated by various popular applications (forums, cms, ecommerce solutions) and custom scripts.
A MySQL query is considered slow and heavy when it is executed for longer than 1 second. Such queries are not common and that’s why they are logged for additional troubleshooting. Every host keeps such logs (when there are any) and should provide them upon customer’s request. Once your host provides you with the slow queries log, you will know which MySQL queries are slow. Then you can begin optimizing your code and database. There are many useful resources on the web to get you started but very often this task requires advanced programming skills.
- Slow inclusion of remote scripts and resources – this is the case when you include RSS feeds, flash animations, banners and others.
When you include remote resources you are already slowing down your site. Sometimes this will have little or no effect (Google Adsense for example), other times it will slow down pages with seconds (RSS news feeds). A good practice is to make sure that the remote resource is not downloaded for each site visit. For example, if you have a news RSS feed, you should set a cron to download the news each hour and then include it in your page. Generally, any kind of content caching will help in such cases. Unfortunately, this is not applicable for dynamically loaded content when it is important to have fresh results (gaming servers status queries). In such cases you can do little but to accept this drawback.
- Slow inclusion of local scripts and resources – usually this is when your pages are overpopulated with content. Other times there are slow / looping scripts executed, images / animations are loaded incorrectly.
The first case is when a page includes too many articles, chatboxes, weather modules, flash animations, etc. Then, in order your page to load it will execute hundreds of sub-scripts which make many database queries, load content worth megabytes and so on. If you take a look at popular web sites or portals, you will find that most of them are kept as compact as possible. This is because each additional content slows down regardless of how powerful the host server is. This is exactly what we recommend – keep your website as compact as possible. Adding too much content usually just slows down your website and confuses your visitors. Other times there are just buggy scripts making loops, others which are being closed incorrectly and so on. Slow scripts may also include incorrectly resized graphics or try to preload big flash animations. In such cases it is a good idea to try opening images / flash animations outside of your scripts and see how long it takes them to load.