WordPress.org

Making WordPress.org

Opened 5 weeks ago

Last modified 5 weeks ago

#5072 new enhancement

Forum posts should prefetch gravatar.com

Reported by: jonoaldersonwp Owned by:
Milestone: Priority: normal
Component: Support Forums Keywords: seo performance
Cc:

Description

Forum posts, such as https://wordpress.org/support/topic/fb-login-doesnt-work-mobile/, load user a JS file (gprofiles.js) from gravatar.com. This is a cold connection to an external domain, and as such is noteably slow.

We should address this by adding a DNS prefetch tag to the <head>, as follows: <link rel='dns-prefetch' href='//gravatar.com' />

Change History (2)

#1 @coffee2code
5 weeks ago

Is gprofiles.js used solely for Gravatar hovercards? If so, then do we even need this script reference?

The only place that I can think of that uses hovercards is the wporg-breathe theme (used for the Make sites). That theme includes the JS file itself via https://secure.gravatar.com/js/gprofiles.js (courtesy of Jetpack) (in the code below you can see how the global gprofiles.js is excluded due to 'grofiles-cards' being queued).

Other places that display Gravatars are the support forum individual topic pages, individual plugin pages, and individual profile pages. In all cases, a Gravatar image from //secure.gravatar.com is used without hovercard support.

Locally I removed the following lines from the (closed-source) global header.php file and haven't noticed any difference so far in behavior regarding Gravatar functionality around the ecosystem.

<?php
if ( ! function_exists( 'wp_script_is' ) || ! wp_script_is( 'grofiles-cards', 'queue' ) ) :
    ?>
<script type="text/javascript" src="https://gravatar.com/js/gprofiles.js"></script>
    <?php
endif;

Am I overlooking something?

Seems we can:

  1. Remove the above global header inclusion of gprofiles.js
  2. Add a prefetch for <link rel='dns-prefetch' href='//secure.gravatar.com' /> (Should this be done simply for everywhere in an unconditional basis via the global header, or on a site-by-site basis depending on Gravatar usage?)

#2 @jonoaldersonwp
5 weeks ago

Oh, excellent work! Yeah, let's kill that everywhere we can. Should have a big impact.

Let's avoid adding a global prefetch for now; it'll impact performance on pages where we're not loafing Gravatar stuff (and I'm also wondering if we should ditch the secure subdomain to reduce the number of different domain lookups).

Note: See TracTickets for help on using tickets.