Remove avatars from comments

When an article has many comments, the avatars within those comments can represent a large percentage of your overall page size. You can drastically decrease the load time on your popular articles by removing the avatars.

You could go to Settings > Discussion to disable avatars sitewide, but this will also remove author avatars as well.

If you are using avatars in an author box above or below the post, you should use the following code to remove only the avatars in the comments area. Place this in your theme’s functions.php file or a core functionality plugin.

/**
 * Remove avatars from comment list
 * @link https://www.billerickson.net/remove-avatars-from-comments/
 */
function be_remove_avatars_from_comments( $avatar ) {
	global $in_comment_loop;
	return $in_comment_loop ? '' : $avatar;
}
add_filter( 'get_avatar', 'be_remove_avatars_from_comments' );

For more performance recommendations, see 10 ways to speed up your WordPress website

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk

Reader Interactions

Comments are closed. Continue the conversation with me on Twitter: @billerickson

Comments

  1. Álvaro says

    “You can drastically increase the load time on your popular articles by removing the avatars.” I believe you mean “decrease the load time”. Right?

    Thanks for sharing.