Why You Should Be Using Locally Hosted Gravatars

As many of you know I am a big fan of Disqus and using a click to load comments setup. However I also use native WordPress comments on my personal site: brianleejackson.com. I am a stickler when it comes to speed and noticed tons of HTTP requests loading out to gravatar.com. So I decided to come up with a better solution.

Using locally hosted gravatars decreased my site load time by over 2 seconds!

Site Using Default WordPress Gravatar Setup

By default with the native WordPress commenting system it pulls a gravatar image for each user’s comment based on their email address. If it can’t find one it uses the default image from gravatar’s server. What this ends up doing is creating a ton of HTTP requests for each image as well as unnecessary redirects. Below is an example from my brianleejackson.com site.

gravatar redirects

Here is a speed test with the default setup. Make a note of the # of requests, 141.

site speed default gravatars

You can see the ridiculous amount of components it is querying under the DNS lookups for both 1.gravatar.com and 0.gravatar.com domains.

dns lookups default gravatar

Site Using Locally Hosted Gravatars

So I decided to switch my site to use locally hosted gravatars to minimize all of the redirects and HTTP requests. This also means they would be loading the images from my CDN as well.  Here is a speed test after the configuration change.

site speed local gravatars

You can see simply by changing to locally hosted gravatar images I decreased by load time from 3.36s to 1.27s and decreased the total number of requests from 141 to 59 as well as the page size!

This wipes out the DNS requests to the gravatar domain completely.

How to Setup Locally Hosted Gravatars

Follow the steps below to setup locally hosted gravatars and shave some seconds off of your load times! Now remember this will disable showing other people’s gravatars. But how important is that to you? Is it worth slowing your site down?

Step 1

First we are going to install a free WordPress plugin called WP User Avatar.

Step 2

Once you have the plugin installed in the WordPress dashboard hover over Avatars and click into “Settings.”

avatars settings

 Step 3

In the settings menu click on “Disable Gravatar and use only local avatars.” Then choose a default avatar.

wp user avatar settings

I am not a big fan of the default one from the plugin so I actually uploaded the following image. Feel free to save it from my site and upload it on yours.

gravatar

Step 4

I then go into my WordPress profile and choose a custom avatar for my author profile so it will show up when I comment and reply on my blog.

my personal gravatar

And that’s it! Your site should now run without all those additional queries to gravatar’s servers. And if you have a CDN implemented they will also load quicker!

Alternative Solution

Pascal from SpinPress also suggested a great alternative WordPress plugin: FV Gravatar Cache

This plugin solves the gravatar problem by problem by:

  • caching gravatars with WordPress cron job
  • caching gravatars on comment submission
  • maintaining a single copy of the default gravatar instead of downloading it again and again for all the email addresses with no gravatar associtated

Both of the above solutions are great ways to solve this problem. As always feel free to leave your comments below.

GET MORE STUFF LIKE THIS

Marketing, WordPress, Blogging Tips, SEO and Reviews, once a week.

20 Comments

  1. Tim J December 28, 2014
    • Pascal Birchler December 28, 2014
      • Tim J December 28, 2014
        • Brian Jackson December 28, 2014
      • Brian Jackson December 28, 2014
        • Pascal Birchler December 29, 2014
          • Brian Jackson January 4, 2015
          • Alec Kinnear April 1, 2016
      • Brian Jackson December 28, 2014
  2. Jaime Pascual December 29, 2014
  3. Gabriel Livan April 4, 2015
    • Brian Jackson April 18, 2015
  4. Greg October 14, 2015
  5. Hasibul Kabir November 15, 2015
  6. Brian Jackson April 3, 2016
  7. Ravi GH February 21, 2017
  8. Abby March 10, 2017
  9. application of e-commerce March 24, 2017

Add Comment

6 Shares
Tweet
Share
Share
Buffer