Every comment on a WordPress blog post loads a Gravatar image from Gravatar’s servers. That’s an external DNS lookup, an external HTTP request, and an image download for each commenter — and those requests happen in parallel before your page finishes loading. A post with 50 comments makes 50 Gravatar requests on every page view. At scale, this is a measurable page speed problem.
There are three ways to fix it, depending on how much you want to remove versus optimise. This guide covers all three, plus how to verify the fix worked.
Why WordPress Comment Avatars Hurt Page Speed
WordPress uses Gravatar (Globally Recognised Avatar) as its default avatar service. When a user comments on your post, WordPress generates an <img> tag pointing to https://secure.gravatar.com/avatar/[md5-hash-of-email]. The browser then has to:
- Resolve the DNS for
secure.gravatar.com(one-time, but still a lookup) - Open an HTTPS connection to Gravatar’s CDN
- Download the avatar image (typically 48×48px to 96×96px)
Modern HTTP/2 multiplexes these requests over a single connection, which reduces the overhead compared to HTTP/1.1 — but you’re still making external requests to a third-party server you don’t control. If Gravatar’s CDN is slow, or down, or rate-limited, that’s browser time wasted waiting for images that have nothing to do with your content.
For blogs with active comment sections — more than 20 or 30 comments — Gravatar requests are a genuine contributor to slower Largest Contentful Paint (LCP) and Time to Interactive (TTI). For posts with hundreds of comments, it becomes significant. For posts with five comments, there are bigger fish to fry. The right fix depends on how active your comment section actually is.
Method 1: Disable All Avatars via WordPress Settings
The simplest option. No code required, and it takes about 30 seconds:
- In your WordPress admin dashboard, go to Settings → Discussion
- Scroll to the Avatars section
- Uncheck Show Avatars
- Click Save Changes
This disables all avatar output sitewide — comment avatars, author avatars, author bio avatars, everywhere. WordPress stops calling the Gravatar API entirely. No Gravatar images are loaded, no Gravatar requests are made.
When to use this: If you don’t display author avatars anywhere prominent on your site, or if you’re happy to remove them entirely for the performance gain, this is the right call. It’s the most complete fix.
Drawback: It removes the author avatar in your post byline and author bio section as well. If your theme shows an author photo in the post header — common on publication-style themes — this will blank it out. Check your theme before applying this sitewide.
Method 2: Remove Comment Avatars Only, Keep the Author Avatar
The original reason this article exists. If you want to keep the author avatar in your post byline or bio but strip avatars from the comment list, WordPress’s get_avatar filter gives you a clean hook to do it.
Add the following to your theme’s functions.php file (or a site-specific plugin if you want to keep it theme-independent):
/**
* Remove avatars from the comment list only.
* The author avatar in bylines/bios is unaffected.
*/
function ajk_remove_comment_avatars( $avatar ) {
global $in_comment_loop;
return $in_comment_loop ? '' : $avatar;
}
add_filter( 'get_avatar', 'ajk_remove_comment_avatars' );
How this works: WordPress sets the $in_comment_loop global to true while iterating over the comments list (inside wp_list_comments()). The filter checks that flag. If we’re inside the comment loop, return an empty string — no avatar rendered, no Gravatar request made. Outside the comment loop (author byline, bio box), the filter passes through the original $avatar value unchanged.
Where to add this code: The safest place is a child theme’s functions.php, so it survives parent theme updates. If you’re using a parent theme directly and don’t want to create a child theme, a minimal site-specific plugin also works — create a file in wp-content/plugins/ with a plugin header comment and add the function there.
What this does not do: This approach stops WordPress from rendering the avatar <img> tag inside comments. Since the tag is never output, the browser never makes the Gravatar request. The Gravatar API is not called at all for comment avatars when this filter is active.
Method 3: Lazy-Load Comment Avatars
If you want to keep avatars visible but prevent them from blocking initial page load, lazy-loading is the modern approach. Browsers support the native loading="lazy" attribute on <img> tags — images below the fold don’t load until the user scrolls toward them.
WordPress’s get_avatar filter passes the full rendered <img> HTML as a string. You can add the loading attribute by patching it:
/**
* Add native lazy-loading to all WordPress avatar images.
*/
function ajk_lazy_load_avatars( $avatar ) {
return str_replace( ' src=', ' loading="lazy" src=', $avatar );
}
add_filter( 'get_avatar', 'ajk_lazy_load_avatars' );
This patches every avatar <img> tag sitewide — comments, author bios, everywhere — to include loading="lazy". Avatars above the fold (typically the author avatar in the byline) still load immediately because they’re in the viewport. Avatars in the comment section, which is usually further down the page, defer until the user scrolls toward them.
Core Web Vitals impact: Lazy-loading below-fold images directly reduces the initial page weight the browser has to handle before the Largest Contentful Paint event. For comment-heavy posts, this is a meaningful LCP and TTI improvement without removing avatars entirely.
Browser support: loading="lazy" is supported in all modern browsers (Chrome, Firefox, Safari, Edge). Older browsers that don’t support it simply ignore the attribute and load images normally — graceful degradation, no JavaScript required.
Note: You can combine Methods 2 and 3 if you want lazy-loaded author avatars but no comment avatars at all — run both filters, with Method 2’s $in_comment_loop check removing comments and Method 3’s attribute patch applying to the remaining (non-comment) avatar calls.
Verifying the Fix
After applying any of these methods, confirm the Gravatar requests are actually gone:
Browser DevTools
- Open the post in a browser and open DevTools (F12 or Cmd+Option+I)
- Go to the Network tab and reload the page
- Filter by Img or search for
gravatarin the filter box - After Method 1 or 2: you should see zero
secure.gravatar.comrequests - After Method 3: Gravatar requests should appear only after you scroll down to the comment section
PageSpeed Insights
Run the post through PageSpeed Insights before and after. Look for:
- Reduce unused JavaScript and Eliminate render-blocking resources reports — Gravatar requests won’t appear here, but their removal helps with the baseline numbers
- Avoid chaining critical requests — Gravatar requests, especially on posts with many comments, can appear here as a chain if they’re loading during the critical render path
- Overall LCP score: on comment-heavy posts, removing external avatar requests typically improves LCP by 100–500ms depending on network conditions and comment count
Which Method Should You Use?
- No avatars anywhere: Settings → Discussion → uncheck Show Avatars. Done in 30 seconds, no code.
- Keep author avatar, remove comment avatars: Method 2 (functions.php filter). The right balance for most blog setups.
- Keep all avatars, improve performance: Method 3 (lazy-load filter). Best for sites where commenter identity matters — community forums, membership sites, heavily commented news posts.
- Your site has fewer than 20 comments per post: The performance gain from any of these is marginal. Focus on larger wins first — caching, image compression, hosting choice. See the WordPress post-launch checklist for where avatars sit in the priority order.
Related Performance and Comment Settings
Avatars are one piece of WordPress comment performance. While you’re in Settings → Discussion, two other settings are worth checking:
- Break comments into pages: Under Discussion → Other comment settings, enable “Break comments into pages” and set a threshold (25–50 per page). Loading 200 comments at once is a bigger performance hit than the avatars.
- Comment spam filtering: Akismet or similar spam filters run server-side, not client-side, so they don’t affect page load time. But reducing the number of spam comments that reach moderation reduces your overall comment count and therefore the number of avatars rendered. See how to stop spam on WordPress forms and comments.
For a full approach to keeping your WordPress site fast and maintained, the complete WordPress maintenance guide covers caching, updates, database cleanup, and performance monitoring as a recurring practice rather than a one-off fix.


