What is the cause of website waiting times?

I’ve been developing a new WordPress Theme and it’s fair to say I’m a little disappointed with its loading times.
After testing it with Pingdom Tools it achieves somewhat random scores (between 70 and 90) and loading time takes around 3 seconds - Far too long!

According to its analysis most of the time is spent waiting for the actual domain (the first request) - This has a waiting time of 2 seconds and nothing else even gets requested until this finishes.
You can see the analysis here:

It would be much appreciated if any of you experts could explain what is or may be causing such a ridiculous waiting time. I’m not sure I can blame this on my hosting since the default WordPress theme “TwentyEleven” loads rather quickly.

Thankyou.

Verify the following:

  1. DNS is set up correctly
  2. Redirects in Apache conf, htaccess files are all correct, or if you’re using some other webserver then check the specific configs.
  3. Application level bottlenecks. Use a profiler like xdebug (with webgrind) or xhprof to see where your bottlenecks are in the source code.

Wordpress is a big bloated script. A 3 second load time (from the time you hit the Enter key to when the site renders in your browser) is quite reasonable. But that isn’t the problem with your site.

Your site has 73 requests to servers. That is an awful lot. You have 5 CSS files, 16 Javascript files, and you are pulling some of these files from external sites like Facebook and Google (for ads). Your main page has 17.21 kB of HTML and 660 kB of CSS, JS, images, and who know what else. Not very efficient if you ask me. All this takes time to load.

Given how much stuff your site is pulling in, I think it loads very fast. And I don’t know what kind of Wordpress plugins you might be using, which will cause even longer load times.

I don’t think it’s your hosting, either. I don’t think you have much of a problem at all given how many requests your site makes to CSS and JS files. Your site loads acceptably fast everything considered.

Yup, as noted above, I would underline the 73 requests to servers part because that’s where the trouble lies. You need to optimize those scripts. Isn’t there some settings in WP to a) optimize scripts and b) compress the output? I just ran some tests on sites that I built and consider bloated and they had half the number of requests. I’ll bet if you optimize all of those script and css files, you’ll improve your responsiveness.

If anyone wants to see how bloated Wordpress is becoming, just put this line in your theme’s footer.php file right before the </body> tag.

<?php echo '<br/>', count(get_included_files()), ' PHP files were required to generate this page.<br/>';?>

A default installation of Wordpress 3.4.2 using the default Twenty Eleven theme requires 83 PHP files to generate the index page (up to the point of the footer.php file). That’s a lot of files that need to be read, loaded into memory, and executed if you aren’t using an accelerator (as most shared servers are not). Add a plugin and that number goes up. Add a few plugins and that number could easily top 100. Wordpress will never be anywhere near as fast as serving up static HTML files.

Indeed WordPress is quite bloated but still it is a fantastic piece of software and I’ll continue to use it. It’s only my theme which seems to be causing loading problems.

I concluded that over 30 of the requests were being made to facebook, but Facebook being a CDN it delivered all it’s stuff in less than 80mS so that’s not really the problem.
The queries to the database took less than 40mS so that’s not the problem either.

Most of the bandwidth was being taken by images despite the fact I’ve used as many sprites as I can (only 24 image requests). I’ve done a little bit of work, knocked 6 HTTP requests off and reduced the page size by 90kB.
Now alot of the time is being taken up by the connect routine rather than wait or receive.

It’s down to around 2.2s. I’ll continue to work on it, thanks for the input gents!

Try optimizing caching on your site and see if that helps. http://wp.tutsplus.com/tutorials/scaling-caching/wordpress-caching-plugins/

I’ve got caching, I’m user W3 Total Cache. It’s fantastic, reduced load times to less than a second but not all people who are going to use my theme will also use a caching plugin. I need to get it up to scratch before I put it in the Themes Directory.

Got you! If you go to the WP codex, you’ll spot a list of links to external resources that deal with optimization of a WP site: https://codex.wordpress.org/WordPress_Optimization

Perhaps you’ve already gone through these, but it you haven’t, perhaps there’s some info that you can use.

As already mentioned by cheesedude, your theme seems to be okay in terms of performance. You may compare it with how fast a default theme loads (or with any popular themes in the official WP directory).

Although it’s always a good idea to reduce the number of HTTP requests, your Pingdom analysis reveals that that’s not your biggest problem yet. A little more than half your total time is spent just waiting for the HTML to be returned. That means the problem is in the PHP of your theme. The usual culprit of slow PHP is database requests. We could give you more specific tips, but we’d have to see your theme code.

But what kind of performance would we expect to see from a shared web host? Also, does the location of the Pingdom test have anything to do with the server wait time (which was 1.59 seconds)? The web server is located in the UK and the original Pingdom test was conducted from a server in Texas, USA.

Tested from Dallas, Texas, USA on October 6 at 19:15:11

I just tested it on a Sunday afternoon (in the USA, evening in the U.K.) using the Netherlands as the testing location and the wait time was 14 milliseconds. But Sunday isn’t peak time, not like a week day. And the number of server requests has been reduced down to 37 now.