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. By removing comment avatars you can increase your site speed.

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

The code below will only remove avatars in the comment area.

<?php
/**
* Remove avatars from comment list
* @see https://www.billerickson.net/code/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' );
view raw functions.php hosted with ❤ by GitHub

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

comments performance

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

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

Let's Talk