Shiba

Adventures in WordPress

  • Home
  • Dog
  • Art
  • Contact
  • WordPress Articles
    • WP Plugins
    • WP Programming
    • WP Admin Panels
    • WP Theme Design
    • WP How-To
    • WP Theme Images
You are here: Home / WordPress Programming / Gravatars Can Slow-Down Your WordPress Blog

Gravatars Can Slow-Down Your WordPress Blog

by ShibaShake 5 Comments

Depending on time of the day and number of comments, using WordPress gravatars can cause a significant slow-down in your blog load time.

Last week, I noticed a significant slow-down in one of my blogs. Pages were taking about 8-10 seconds to load, when previously they would load almost instantaneously.

There are several ways to address this issue –

1. Turn-off Gravatars

WordPress dashboard screen-shot of Avatar controls.
WordPress dashboard screen-shot of Avatar controls.

How to turn off gravatars –

  • Go to Settings >> Discussion.
  • Scroll down to the bottom of the screen to the Avatar section.
  • Under Avatar Display select Don’t Show Avatars.

However, turning off gravatars will make your WordPress blog comments section less personalized, and less visually compelling.

2. Set Number of Comments

Another way to deal with slow load-time is to reduce the number of comments shown on each page.

Again go to Settings >> Discussion. The last bullet under Other Comment Settings allows you to set the maximum number of comments shown on each page.

You can also set the order in which the comments are displayed, e.g. display newer or older comments first.

WordPress dashboard screen-shot of 'Other Comment Settings'
WordPress dashboard screen-shot of 'Other Comment Settings'

Limiting the number of comments per page, however, will make it less likely for users to read all the comments.

In addition, it may confuse search engines, causing you to lose the keyword value of your comments, or worse, result in duplicate content penalties.

3. Use Your Own Gravatars

Using local gravatar images lets you control the look of your blog, and removes the added time overhead of accessing the gravatar.com site.

To use local gravatar images, add the function below into your theme functions.php file.

function local_gravatar($comment, $dim) {
	static $gravatar_img = NULL;
	if (!strcmp($comment->comment_author, "YOUR_USER_ID"))
		return "<img src='YOUR_IMAGE.JPG'" . "' width='" . $dim . "' height='" . $dim . "' />";
	
	// Return a gravatar image based on IP
	$img_num = intval($comment->comment_author_IP);
	if (!$gravatar_img) {
		$gravatar_img = get_gravatar_images();
		if (!$gravatar_img) return NULL;
	
		$gravatar_img = explode('|', $gravatar_img);
	}
	$img_count = count($gravatar_img);
	$index = abs($img_num % $img_count);
	
	// Construct new image http
	$img_uri = "<img src='" . get_theme_mod('gravatar_dir') . $gravatar_img[$index] . "' width='" . $dim . "' height='" . $dim . "' />";
	return $img_uri;
	
}

Lines 3-4 – Checks for your user-ID and returns a special predefined image.

Lines 7-19 – For all other users, we return a local gravatar image based on their IP. You can also return gravatar images based on e-mail or website.

To do this replace $comment->comment_author_IP on Line-7 with $comment->comment_author_email or $comment->comment_author_url.

Note – In Line-9 we call the get_gravatar_images function which retrieves an appropriate image from a list of images in your local blog directory.

Here is the source code for the get_gravatar_images function.

Below are a set of gravatar images I created for my Shiba WordPress theme. Feel free to use them as your initial example gravatar images.

Face1
Face2
Face3

Face5
Face7
Face8

Face9
Face10
Face11

Face12
Face13
Face14

Face15
Face16
Face17

Face18
Face19

This is an example WordPress blog page with over 100 comments, using the local_gravatar function above.

4. Use a Gravatar Cache Plugin

There are also a variety of plugin-ins that allow you to cache gravatar results locally so that your blog does not need to keep accessing the gravatar.com site.

Here is a list of other great WordPress optimization tips by Vladimir Prelovac.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Comments

  1. Craig says

    November 11, 2010 at 3:30 am

    You absolute moron. Gravatar.com is highly tuned to serve avatars and does a better job at it than most people’s piss-ant hosting can. Comment paging is the answer.

    Reply
    • ShibaShake says

      November 11, 2010 at 8:17 am

      Perhaps you were too busy to read the article before leaving a comment. In the article I have a whole section on –

      2. Set Number of Comments

      Another way to deal with slow load-time is to reduce the number of comments shown on each page.

      Again go to Settings >> Discussion. The last bullet under Other Comment Settings allows you to set the maximum number of comments shown on each page.

      This article has page speed tests as well as a detailed explanation of gravatars and page speed.

      http://www.seomofo.com/wordpress/comments-slow-page-speed.html

      Here is an excerpt from the article –

      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.
      ~~[SEOmofo]

      This article on rude people may also be helpful.
      http://shibashake.com/dog/rude-dogs-and-rude-people#rude-people

      Reply
      • Roee Yossef says

        March 21, 2016 at 12:27 pm

        Love it Shiba !

Recent Posts

  • Screenshot of an example article in code view of a modified Gutenberg editor.How to Harness the Power of WordPress Gutenberg Blocks and Combine It with Legacy Free-Form Text
  • Screenshot of the Success, WordPress has been installed page.Migrating Your WordPress Website to Amazon EC2 (AWS)
  • Screenshot of WinSCP for creating a SFTP configuration.How to Set-Up SFTP on Amazon EC2 (AWS)
  • WordPress Gutenberg code view screenshot of this article.How to Prevent Gutenberg Autop from Messing Up Your Code, Shortcodes, and Scripts
  • Screenshot of the Success, WordPress has been installed page.How to Create a WordPress Website on Amazon EC2 (AWS)

Recent Comments

  • Screenshot of the Success, WordPress has been installed page.How to Create a WordPress Website on Amazon EC2 (AWS) (1)
    • Erik
      - Great article. All worked great except for this step:apt install php-mysqlChanging to this fixed it:apt install ...
  • Add Custom Taxonomy Tags to Your WordPress Permalinks (125)
    • Anthony
      - Where does this code go? Like, what exact .php file please?
  • Screenshot of an example article in code view of a modified Gutenberg editor.How to Harness the Power of WordPress Gutenberg Blocks and Combine It with Legacy Free-Form Text (1)
    • tom
      - hi,my experience was like the same, but for me as theme developer the "lazy blocks"(https://wordpress.org/plugins/lazy-blocks/) ...
  • WordPress Custom Taxonomy Input Panels (106)
    • Phil T
      - This is unnecessarily confusing. Why declare a variable with the same name as your taxonomy? Why did you choose a taxonomy ...
  • Create Pop-up Windows in Your WordPress Blog with Thickbox (57)
    • Jim Camomile
      - I have used this tutorial several times and it is one of the few simple and effective ways to add popups with dynamic content, ...

Copyright © 2024 · Genesis Skins by ShibaShake · Terms of Service · Privacy Policy ·