Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gravatar-hovercards: Only load when gravatars are on the page #14922

Merged
merged 1 commit into from
Mar 17, 2020

Conversation

dero
Copy link
Contributor

@dero dero commented Mar 8, 2020

Fixes #14860

Changes proposed in this Pull Request:

  • Dequeue the FE assets when there are no gravatars on the page to be displayed.

Is this a new feature or does it add/remove features to an existing part of Jetpack?

  • This updates the existing gravatar-hovercards module.

Testing instructions:

  • Go to Jetpack Settings > Discussion > Comments.
  • Enable pop-up business cards over commenters’ Gravatars.
  • Enable a theme that displays user avatars, e.g. twentysixteen.
  • Go to a single post and observe the gravatar being displayed.
  • Hover over the gravatar and observe the business card to pop-up.
  • Open the browser's dev tools and check that https://secure.gravatar.com/js/gprofiles.js and wpgroho.js assets are loaded.
  • Go to any page (as in page post type) and observe no gravatars on the page.
  • Open the browser's dev tools and check that https://secure.gravatar.com/js/gprofiles.js and wpgroho.js assets are NOT loaded.

Proposed changelog entry for your changes:

  • Gravatar hovercards do not load assets on the front-end when there are no avatars on the page.

@dero dero added [Feature] Gravatar Hovercards [Focus] Performance [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Mar 8, 2020
@dero dero requested a review from a team as a code owner March 8, 2020 18:03
@dero
Copy link
Contributor Author

dero commented Mar 8, 2020

@kienstra Could you please review this PR? Thanks.

@jetpackbot
Copy link

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: April 7, 2020.
Scheduled code freeze: March 31, 2020

Generated by 🚫 dangerJS against 72ab5be

@kraftbj
Copy link
Contributor

kraftbj commented Mar 9, 2020

Flyby thought - I'm trying to think of if there any situations with Infinite Scroll where the first load would have no gravatars, but the second load would. A theme with gravatars in the comments only?

@dero
Copy link
Contributor Author

dero commented Mar 9, 2020

@kraftbj That's a good point. I've tested that scenario and I don't think the existing scripts take dynamically loaded markup into account either:

  • Switched to twentysixteen with enough posts.
  • Enabled infinite scrolling.
  • On the homepage, hovered over avatars and saw business cards hover.
  • Loaded a second page of posts using the infinite scroll button.
  • Hovered over the newly loaded avatars.
  • No business cards popped up (even though the author was the same).

A quick scan of the JS sources also indicates the feature is only initialized once on top of the markup present on page at that point. I don't think this PR introduces a regression.

@kienstra
Copy link
Contributor

kienstra commented Mar 11, 2020

Looks great!

Hi @dero,
This looks really good.

The 'hovercard' still works fine when there is a gravatar on the page:
test-j

And as expected, the wpgroho.js and gprofiles.js scripts aren't present when there is no gravatar, like on a post with no comment:
not-in-src

Sorry for the delay.

@jeherve jeherve added this to the 8.4 milestone Mar 11, 2020
@leogermani
Copy link
Contributor

Hi @dero ,

I didn't manage to test the infinite scroll scenario to assure there is no regression. Twenty sixteen will only display gravatars on singles so I can't see them on home page or any other archive.

Do you have any tips on how to test it?

Thanks

@dero
Copy link
Contributor Author

dero commented Mar 17, 2020

Do you have any tips on how to test it?

Sure, @leogermani, I'd suggest two different ways:

  1. Using a theme that displays gravatars by default on the home page. For example the Bam theme does that. Enable it and test the behavior with and without this patch.
  2. Updating one of the official twenty* themes to display gravatars as well. I don't think any of them display gravatars by default, but users can modify them / hook into them to add gravatars. For example you could update this line of twentytwenty to be this instead:
<?php echo get_avatar( get_the_author_meta( 'ID' ) ); ?>

It won't be pretty, but it will get the job done.

@leogermani
Copy link
Contributor

Hi @dero,

Thanks for the detailed instructions. I saw your comment only mentioning activating the twentysixteen and I thought I could be doing something wrong.

Just confirmed the bug is already there before this PR

Copy link
Contributor

@leogermani leogermani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes work as expected.

I can confirm that the infinite scroll issue is not a regression and I've opened another issue to document this -> #15012

@leogermani leogermani merged commit 25080d6 into master Mar 17, 2020
@leogermani leogermani deleted the update/gravatar-hovercards-conditional-load branch March 17, 2020 14:31
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Mar 17, 2020
@dero
Copy link
Contributor Author

dero commented Mar 17, 2020

I saw your comment only mentioning activating the twentysixteen and I thought I could be doing something wrong.

@leogermani Gotcha. I think I just forgot that I've updated the theme to be able to test in the first place. Thanks for the review and testing here!

jeherve added a commit that referenced this pull request Mar 20, 2020
jeherve added a commit that referenced this pull request Mar 31, 2020
* Initial changelog entry

* Changelog: add #14904

* Changelog: add #14910

* Changelog: add #14913

* Changelog: add #14916

* Changelog: add #14922

* Changelog: add #14924

* Changelog: add #14925

* Changelog: add #14928

* Changelog: add #14840

* Changelog: add #14841

* Changelog: add #14842

* Changelog: add #14826

* Changelog: add #14835

* Changelog: add #14859

* Changelog: add #14884

* Changelog: add #14888

* Changelog: add #14817

* Changelog: add #14814

* Changelog: add #14819

* Changelog;: add #14797

* Changelog: add #14798

* Changelog: add #14802

* Changelog: add #13676

* Changelog: add #13744

* Changelog: add #13777

* Changelog: add #14446

* Changelog: add #14739

* Changelog: add #14770

* Changelog: add #14784

* Changelog: add #14897

* Changelog: add #14898

* Changelog: add #14968

* Changelog: add #14985

* Changelog: add #15044

* Changelog: add #15052

* Update to remove Podcast since it remains in Beta

* Changelog: add #14803

* Changelog: add #15028

* Changelog: add #15065

* Changelog:add #14886

* Changelog: add #15118

* Changelog: add #14990

* Changelog: add #14528

* Changelog: add #15120

* Changelog: add #15126

* Changelog: add #15049

* Chanegelog: add #14852

* Changelog: add #15090

* Changelog: add #15138

* Changelog: add #15124

* Changelog:add #15055

* Changelog: add #15017

* Changelog: add #15109

* Changelog: add #15145

* Changelog:add #15096

* Changelog:add #15153

* Changelog: add #15133

* Changelog: add #14960

* Changelog: add #15127

* Changelog: add #15056

* Copy current changelog to changelog archive.

* Clarify changelog description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gravatar Hovercards Load When There Are No Gravatars
7 participants