There has been a lot of buzz lately about page speed. Matt Cutts has commented about how page speed might be added as a signal to Google’s ranking algorithm, sometime in the future. Google has released the Site Performance feature in the Labs section of Google Webmaster Tools, despite the fact that it’s useless. And of course, all the popular SEO/SEM blogs have predictably started churning out virtually-useless blog posts about how to make your website faster.
Regardless of whether or not Google makes page speed a ranking factor, optimizing page load times and overall site speed is a best practice that all web developers should be mindful of. Besides, if the Site Performance Lab is any indication, I’d say Google won’t have their page speed data signal “production-ready” for another 15 years. Using the Google Toolbar to detect page load times is quite frankly one of the dumbest ideas I’ve ever heard, and I sincerely hope it’s just another scare tactic to get webmasters’ minds off of SEO and PageRank (and onto something that actually benefits Google). I don’t know how Google collects the speed data they use in their AdSense quality score, but I pray to God it’s more robust than this Site Performance joke. Anyway, rants aside, the fact remains that everyone is suddenly very interested in making their websites faster…and this post is going to address one small piece of that puzzle: WordPress comments.
How does WordPress handle comments?
When WordPress responds to a page request, it has to figure out how to output the comments associated with that particular post. Here is a very basic overview of the steps WordPress follows:
- Fetch the comments from the
wp_commentsdatabase table. - For each comment that matches the page ID being served, loop through and insert the raw data into HTML code. Here’s a simplified example:
<h6><a href="comment_author_url">comment_author</a></h6>
<p>comment_date</p>
<p><img src="http://www.gravatar.com/avatar/comment_author_email /></p>
<p>comment_content</p>
How does WordPress handle Gravatars?
If a post has 0 comments, the steps shown above end pretty quickly because there’s nothing more for WordPress to process. However, even if a post has several comments to process, the computation cost is relatively insignificant when you compare it to the cost of downloading each commenter’s Gravatar. In other words, WordPress can build the HTML page pretty quickly and send it to your browser, but then your browser still has to request the Gravatar images from gravatar.com. As you’re about to see, it is the multiple HTTP requests for Gravatar images that really slow down your pages. I’ll try to explain why that is…by giving you an overview of how Gravatar works (as I understand it). Here’s the gist:
- For each comment, WordPress takes the commenter’s email address and applies the md5 hash algorithm to it (in order to protect commenters’ email addresses).
- The hash is attached to a gravatar.com URL, which creates the src destination for the Gravatar’s img tag. For example:
<img src="http://www.gravatar.com/avatar/3904bc1a75d86eb05dd07425214002df" /> - After the HTML page is sent to your browser, your browser sends a request to Gravatar’s servers for each Gravatar image embedded in the comments.
- Gravatar’s servers check their records for the hashed email address. If it exists (meaning the email address was registered at gravatar.com), Gravatar returns the corresponding image. If it doesn’t exist, Gravatar redirects to your blog’s default image, which you can select from the WP admin menu for
Settings→Discussion:
Why do Gravatars slow down WordPress?
Enabling comments and custom Gravatars on your WordPress blog can definitely encourage your visitors to participate and join the conversation, but on the other hand, the Gravatar system has some inherent flaws that negatively impact your page speed. Here are some examples:
- Every comment contains an img element that points to a unique URL on gravatar.com. This means that every single person who comments on your blog post is costing you an extra HTTP request…regardless of whether or not they’ve registered their email address at gravatar.com.
- If a user is NOT registered at Gravatar.com, their image request will be redirected to the default location. This redirect means yet another HTTP request, either to your server or another gravatar.com URL (depending on what you set your default image as).
- Several different src URLs return the same exact image. This is because every email address results in a unique hash, which in turn creates a unique URL. Many of these unique URLs will redirect to the default Gravatar image, because not all your visitors will be signed up for Gravatar. This triggers a “page speed tip” in Google Webmaster Tools that looks like this:
Serve resources from a consistent URL
The following resources have identical contents, but are served from different URLs. Serve these resources from a consistent URL to save 10.7 KB and 5 requests:
- http://www.gravatar.com/avatar/f5264f0487ece922e2f512b58e2bf1d8?s=48&d=http%3A%2F%2Fwww.seomofo.com%2Fwp-content%2Fthemes%2Fthesis_16%2Fcustom%2Fimages%2Fgravatars%2Fc01.png%3Fs%3D48&r=X
- http://www.gravatar.com/avatar/f018690430517b80b907581087479ebf?s=48&d=http%3A%2F%2Fwww.seomofo.com%2Fwp-content%2Fthemes%2Fthesis_16%2Fcustom%2Fimages%2Fgravatars%2Fc01.png%3Fs%3D48&r=X
- http://www.gravatar.com/avatar/5160428f6f123b4bd5b83924eb87fefd?s=48&d=http%3A%2F%2Fwww.seomofo.com%2Fwp-content%2Fthemes%2Fthesis_16%2Fcustom%2Fimages%2Fgravatars%2Fc01.png%3Fs%3D48&r=X
- http://www.gravatar.com/avatar/d36c9a1e57814dfbf9f16457f3f53405?s=48&d=http%3A%2F%2Fwww.seomofo.com%2Fwp-content%2Fthemes%2Fthesis_16%2Fcustom%2Fimages%2Fgravatars%2Fc01.png%3Fs%3D48&r=X
- http://www.gravatar.com/avatar/9081da00619e7205805ecc0735dda190?s=48&d=http%3A%2F%2Fwww.seomofo.com%2Fwp-content%2Fthemes%2Fthesis_16%2Fcustom%2Fimages%2Fgravatars%2Fc01.png%3Fs%3D48&r=X
- http://www.gravatar.com/avatar/b958344045e263b90eb521a64aaedb4e?s=48&d=http%3A%2F%2Fwww.seomofo.com%2Fwp-content%2Fthemes%2Fthesis_16%2Fcustom%2Fimages%2Fgravatars%2Fc01.png%3Fs%3D48&r=X
Page Speed Testing
Below you’ll find some page speed data I collected, using this web page speed tool. It is the same tool Matt Cutts mentioned in his WebPro News interview. The page I used in this test was my article about how stupid people hate Twitter’s new retweet feature, which had a total of 18 comments (from 10 unique users) at the time of testing. The detailed results are linked to below, but I’ve summarized the data results for you as well.
| Load Time |
First Byte |
Start Render |
Requests | Bytes In | Bandwidth | |
| No Comments (1st View) | 0.956 | 0.502 | 0.726 | 20 | 227 KB | 4.09 Mbps |
| No Comments (2nd View) | 0.695 | 0.537 | 0.689 | 2 | 9 KB | |
| Comments | No Gravatars (1st View) | 1.122 | 0.620 | 0.909 | 22 | 238 KB | 3.90 Mbps |
| Comments | No Gravatars (2nd View) | 0.876 | 0.677 | 0.829 | 2 | 20 KB | |
| Comments | Gravatars Default = Blank (1st View) | 1.191 | 0.629 | 0.917 | 37 | 253 KB | 3.70 Mbps |
| Comments | Gravatars Default = Blank (2nd View) | 1.037 | 0.673 | 0.804 | 8 | 23 KB | |
| Comments | Gravatars Default = Mystery Man (1st View) | 1.312 | 0.629 | 0.922 | 38 | 260 KB | 3.12 Mbps |
| Comments | Gravatars Default = Mystery Man (2nd View) | 1.025 | 0.662 | 0.793 | 8 | 23 KB | |
| Comments | Gravatars Default = Custom (1st View) | 1.215 | 0.633 | 0.911 | 37 | 265 KB | 3.77 Mbps |
| Comments | Gravatars Default = Custom (2nd View) | 1.031 | 0.675 | 0.822 | 8 | 23 KB |
For the full results of each speed test, click the links below:
No comments • No Gravatars → Speed Test 1
Comments • No Gravatars → Speed Test 2
Comments • Gravatars • Default is Blank → Speed Test 3
Comments • Gravatars • Default is Mystery Man → Speed Test 4
Comments • Gravatars • Default is Custom → Speed Test 5
What can I do to speed up my comments?
Here are some suggestions for speeding up your WordPress posts by optimizing your comment settings. I will try to list these based on how big of an impact they have on your page speed. The suggestions that could improve your page speed the most are listed first:
- Disable comments completely.
- Load comments dynamically (e.g. a button that says “click here to view comments”).
- Delete any comments that don’t add value to your post. (Ego boosts don’t add value.)
- Disable Gravatars.
- Set your default Gravatar to Blank.
- Set your default Gravatar to a custom image on your server.
- Restrict your Gravatar images to small dimensions (e.g. 32px).
Kill the Smiley Faces!
I just thought of one more setting you can tweak to speed up your WordPress comments. You can UN-check the option that says “Convert emoticons like :-) and :-P to graphics on display.” This will prevent WordPress from having to request the emoticon images such as
and
.
Something I found interesting about WordPress is that the Mystery Man default Gravatar image is stored on gravatar.com. So the reason why the Blank avatar and my custom avatar returned faster page load speeds…is because they are both stored on my own server. Theoretically, you might be able to speed up your page loads by simply saving a copy of Mystery Man to your own server and designating it as your default (I’ll eventually write a post that explains how to do this). Older browsers will only maintain 2 connections to any given host, so if your web browser is requesting ALL the Gravatar images from www.gravatar.com, then it can only grab two at a time. On the other hand, if the default Gravatar image is located on your own server, then your web browser can grab it even when both www.gravatar.com connections are busy.
To put it all in perspective…
After reading a Twitter response to this article, I realized that I wasn’t entirely clear about how much comments slow down WordPress posts…as a relative measurement. I’ll try to put it into perspective for you.
First of all, I only ran the speed tests on one page, so certainly these results will vary, depending on variables such as:
- How fast is your server, compared to gravatar.com’s server?
- How many comments does the WordPress post have?
- How many of those comments are from unique visitors (i.e. unique email addresses)?
- What type of web browser are your visitors using to view the page?*
* Older browsers only permitted 2 persistent connections per host. Newer browsers support more, and therefore multiple Gravatar images can be downloaded from www.gravatar.com in parallel. For more details, see the Roundup on Parallel Connections by website speed guru, Steve Souders.
One of the reasons why my test results only differ by a couple 10ths of a second is because my test page only had 18 comments, and only 10 of those were from unique email addresses. Also, I’ve been busy tweaking. My website, in order to improve overall performance. So try not to think in terms of my specific test page, because this data will mislead you:
- Without any comments, the test page loaded in = 0.956 seconds.
t1 = 0.956s - After I enabled the comments (without Gravatars), the test page required an additional 0.166 seconds to load.
t2 = t1 + 0.166s - After I enabled the Gravatars, the test page required an additional 0.190 seconds to load.
t3 = t2 + 0.190s = t1 + 0.356s
Why is that data misleading?
It’s misleading because some of you [lesser intelligent] people don’t know the importance of relative measurements, and you’ll interpret my data to mean something like this:
Hooray! Comments and avatars only slow down a WordPress post by 0.356 seconds! That’s totally…like…not a long time to wait. Social media really is the best internet marketing strategy evar, tee-hee! I’m gonna put a trillion comments on every page of my site! Even the comments on my comments will have comments!
Instead, look at it from a glass-half-empty point of view:
- Without any comments, the test page loaded in some [unknown] amount of time.
t1 = x - After I enabled the comments (without Gravatars), the test page took 17.3% longer to load.
t2 = (117.3%)(t1) - After I enabled the Gravatars, the test page took 16.9% longer to load than the page without Gravatars. And compared to the first page (which had no comments and no Gravatars), the test page took 37.2% longer to load.
t3 = (116.9%)(t2) = (137.2%)(t1)
Get your math equations out of my face and just spell it out in plain English!
What I’m telling you is…
Adding 18 comments to my blog post made it 37.2% SLOWER.
I’m still not convinced!
Alright, I got another test case for you. This one is a comparison between two different posts on Outspoken Media: one that has 5 comments vs one that has 130 comments. The content isn’t exactly the same, but it’s close enough. No? It’s not close enough? You demand more-accurate testing? Fine, I copied the content portion of these posts, pasted it into empty HTML pages, hosted them on my own site, and ran the tests again on just the content. If you really want to see the difference, the results are here: Page#1 Page#2. The only relevant information those results show is that the page with 130 comments has a slight disadvantage (due to an extra image) and takes 0.2 seconds longer to load (not including the comments, of course). Anyhow…let’s get to the important stuff now. Let’s compare the page load times of the actual posts…comments and all.
Speed Test #1
- Post: It’s Not the Recession, You Just Suck
- 130 comments
- 85 unique Gravatars
- Average load time before cache: 9.315s
- Average load time after cache: 4.155s
- full test results
Speed Test #2
- Post: Penalties, issues and filtering; it’s all just confusing me
- 5 comments
- 5 unique Gravatars
- Average load time before cache: 4.636s
- Average load time after cache: 2.352s
- full test results
In plain English
The results of this second set of tests indicate that…
Compared to the post with 5 comments…the post with 130 comments took roughly TWICE as long to load.
Grand Finale
Click the small green button below to see the waterfall graph comparison between the 130-comment post and the 5-comment post.
{ 49 comments… read them below or add one }
good post mofo
Stop slowing down my page, you jerk!
LOL
Um…never thought of the gravatar addition as a page performance bottleneck, but great catch!
Will need to rethink this for our blog!
Thanks Mofo!
:-)
Jim
WOW! Great info and it makes me think. I don’t use anything to make the comments “fancier”. Glad I haven’t.
What about using something like Intense Debate that loads the comments using javascript after the “page” has loaded.
How do they fit into Google’s version of a fast page ?
That’s an excellent question and one I don’t know the answer to. The Google Toolbar is recording its users’ browser activity…but which parts exactly?
Another way of asking this question is:
Is Google’s Site Performance counting all resource requests sent by your browser for a given page…or is it only counting the requests prior to the onload event?
It seems like a pretty easy experiment…but I’m pretty burned out on page speed right now, so maybe someone else can do it. =)
A similar experiment might be to alter your theme so that avatars are displayed as a CSS background-image of a fixed size div. The page should render before the avatars have all been loaded but, like you say, it depends on G’s site performance criteria.
page speed criteria
This is interesting! Although, it makes me want to post about three hundred comments on your blog ;-).
Don’t forget to use a different email address each time. Otherwise it won’t work.
first time to the seomofo, great post – look forward to learning more.
Darren, you rocked this one, except for the part where you say “I’d say Google won’t have their page speed data signal “production-ready” for another 15 years.”. Sure it will probably take that long, but given how Google’s run by crack addicts, they’ll probably try to implement something this year. And as a result, will screw up their results even more than they already have.
Heh. Yeah…that’s basically what I was trying to say. The post originally referred to Site Performance as a “useless piece of shit” and “a fucking joke,” but then I filtered myself later and lost some clarity in the process. So yes…whether it works perfectly or not, Google’s gonna release it ASAP and try to unfuck it along the way.
A nice jumping off point for looking more closely at Wordpress and site speed. What about those popular tweet count icons? Lots of extra URL requests from third-party servers. And let’s not forget widgets! And when testing for load speed, do we disable Google analytics calls? Care about caching? I get very tired of “Waiting for google-analytics.google.com” in real life,let alone when testing anthing.
And when you get a minute, why not inspect some of the 25 million Wordpress plugins that are promoted on Wordpress.org? You can find some real golden examples of looping mysql calls.
I ditched the Tweetmeme widget. It was crazy-slow, and I couldn’t get it to load dynamically. I’ll try again when I have time. All the widgets I use are HTML-based (i.e. not “smart” widgets), because I load them from an external .js file when you hover over the “Do you like this?” image.
I haven’t been disabling GA in my tests, but you’re right…I’ve seen many-a-page-load get stuck on Google’s damn servers.
Regarding slow WordPress widgets…I’ve noticed that WP Stats is a pretty slow one. As much as I love staring at the graphs all day, I just don’t think it’s necessary–especially when I have GA installed too.
Congrats on making the front page of Sphinn Darren. This article comes at precisely the right time for me. Thanx for the in-depth research into this.
Very interesting deduction that Google actually only wants us to optimise our page speed to satisfy its own results serving needs and not so much for SEO!
Thanx
You could also use comment paging to reduce the number of comments that appear on any given page. Not so great for usability, but hey it’s not like anyone reads anyone else’s comments :-)
How many more comments do I need to add to slow down your load time by 90%? I would like an exact answer so I can make that many comments.
okthxbye
i like rishil, he’s alright – unlike the hostility SEO mofo gives me for praising his original content
This page loads too damn slow.
You sir, are obviously the world’s best looking and most talented SEO EVAR
How’s that?
*collects her $10 and runs away*
You haven’t answered my question yet mofo
Hi Rishil,
In order for me to calculate an exact answer, I would need to know exactly what each theoretical comment’s content would be.
Have you looked at performance with a plugin like wp super cache? It creates a version of the page on the server that does not require any database requests. Possibly, you could approve all of your comments, visit the page logged out, and make sure it has created the server page. The only speed issue associated with the comments would be the added html/text on the page. If super cache works that way.
I guess I will test it out some time. Great post.
Great research to back up your claims… I never really considered how much impact comments and gravatars could have on page load time… so many blogs use gravatars and many of them should definitely take heed to your advice and take them off because they are deathly slow.
That’s a pretty tortoise!
Yo Mofo:
(Never thought I’d get a chance to start a polite comment that way…)
Any temptation to load the Google Analytics JS from your own server to beat the loads getting stuck from “Google’s damn servers”?
I know the asyncronous tag is supposed to alleviate this, but it looks like it will require relearning for additional, more advanced tracking of events etc, so I haven’t gone there yet.
At the risk of sounding like a suck-up… REALLY enjoying the depth of the research in your posts, as opposed to most of the “blown out their ass” nonsense that passes for content on so many sites these days.
Found you circuitously via a tweet about SeoBullshit.com.
Paul
Hi Paul,
Thanks for the compliment. I’m glad you’re enjoying the site. :)
Regarding the possibility of serving the Google Analytics code from your own server…I didn’t know the answer to that, so I searched the Google Help Forums and found this thread. It’s not an official answer from Google, but it’s the best thread I could find.
The general consensus seems to be there are 2 downsides to hosting ga.js yourself: (1) if Google updates their code, your copy will not get updated, and (2) since Google’s copy is used on so many sites, there is a better chance of it already being cached in your users’ web browsers.
Alternatives to Google Analytics were also mentioned, such as Urchin, which is hosted entirely on your own server, and server log-based tracking, which doesn’t make any external requests at all.
But again, this information came from non-Googlers, so if you’re considering doing this…double check these facts.
Sorry to be dense, but how do you disable gravatars in WordPress, by simply disabling avatars?
Hi Eric,
Sorry, I should have been more clear. I use the terms Gravatar and avatar interchangeably in this article. So yes, disabling avatars means the same as disabling gravatars. I’ve updated the image above to include the option that says “Don’t show avatars.”
So, I don’t write plugins, but is it possible to write a plugin that does this:
At the time someone comments, the plugin goes out, gets the Gravatar image, saves is on the server (local) and then the comment img calls point to the server and not Gravatar.
The catch would be if someone changed their Gravatar image, but the next time they comment, the image could be updated. And… how often do people change their Gravatars anyway?
Hi Tom,
I’m sure it’s possible, but it probably wouldn’t be worth the effort. An easier workaround might be to not load the comments unless a user clicks a button to activate them. Or maybe even defer the gravatar requests until after the page has loaded.
With the number of Wordpress plugins growing like rabbits, the speed issue you bring up is going to become more important over time. People add more and more plugins to their WP sites for every little thing without thinking of the consequences.
Of course, what’s the best way to combat slow load times? With another plugin of course! A plugin that does caching that is. I’ve had decent success with WP Super Cache in that regard. Wonder if people here have a favorite caching plugin?
For bigger sites, there are ways to do caching outside of WP. I ran across a blog article the other day about how Harvard is using Nginx to speed up their Wordpress site. Don’t remember the link, but you can just Google it if you’re interested.
Out of curiosity, how did you measure your page load times?
What do you mean? Are you asking what tool I used or what the configuration settings were?
NM … click on the links and saw what tool you were using.
It’s good to have some data on this – thx for the post… cheers mofo
Why not just get rid of all images and serve nothing but text? Woo! It’ll be just like the old days, with Gopher!
Seriously? If you don’t want your site to look good, that’s fine, but don’t claim it’s for performance reasons.
Do you think you’re funny, Otto?
i make piture for u i lik u and u r smart then me
Dear Mike,
We regret to inform you that your comment did not meet the minimum intelligence quotient requirements of this blog, and therefore we have decided to take appropriate actions, in accordance with the regulations set forth in our company policy.
We believe this decision accurately reflects the best interests of our community. We apologize for any inconveniences you may endure as a result, and we wish you the best of luck in your continued search for someone who will listen to anything you have to say.
Sincerely,
The Staff at SEOmofo.com
Someone is bitter because his post was worthless.
Maybe you should take down this picture so your blog will run faster. Still can’t stop laughing kid.
Awww…don’t be bitter, Mikey; I adored your post! It’s not worthless to ME. To me, it was a thoughtful gesture that warmed my heart. And you’re quite the artist!
Golly, where’s a rim shot when you need one? You can draw AND make jokes?! You’re like…some kind of superhero or something. You think YOU’RE laughing…imagine my poor readers when they find your joke; they’ll probably laugh themselves to death!
But I have to say…the thing that amuses me the most is how much harder you tried to use proper grammar and punctuation in your second comment.
Thank’s for the useful post! I’ve just changed my settings =)
Very interesting posting. Thanks for sharing this.
Gravatars seem to slow things a bit down but people like those Gravatars in blogs so i will keep them.
too bad you don’t show my gravatar :) Just kidding.
Very interesting posting. Thanks for sharing this! I think it is quite obvious that it slows the speed of a page as it has to do more connections but how yould it be compared to a website with registration and avatar inside the website?
…glad to see that there are 47 comments on your page now. I feel like you were just asking for that to happen.
It’s like the “tortured artist” guy that pretends like he couldn’t care less about women, but get’s laid whenever he wants :)
Also, food for thought:
With site speed such an issue…why use wordpress and not just hard code your pages?
Me personally? I’m only using WordPress because everyone else is, and without it…I wouldn’t have anything to write about. Honestly, I can’t stand it. Everything takes 5 times as long to accomplish. I use to use Dreamweaver for everything, and I would recommend that over WordPress any day.