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

Fix bad CLS score on main product when video is the featured media #1412

Merged
merged 1 commit into from
Feb 25, 2022

Conversation

ludoboludo
Copy link
Contributor

Why are these changes introduced?

Fixes #1165

What approach did you take?

There are 80 lines of CSS in component-deferred-media.css which were loaded asynchronously on main-product.iquid and a few other files.

I've changed it so the asset is loaded right away so that if some of the first medias are videos then it won't cause any CLS issues.

Before and after lighthouse scores on mobile:

Other considerations

A few other files do call that file asynchronously, so that problem might happen there as well but because it's section it's not possible for us to say if they're going to be the first thing loading at the top of the page or not.

Here is the list of places:

  • collage.liquid
  • featured-product.liquid

Testing steps/scenarios

  • You can try and load main locally, remove the dynamic checkout button and go to the Test 3D models, video product which is showing on the home page and feat. collection, using lighthouse in the inspect tool. Test for mobile and desktop.
  • Then do the same thing on this test theme/branch to compare the results.
  • Test other products to make sure it hasn't impacted in any way their performance.

Demo links

Checklist

@andrewetchen andrewetchen self-requested a review February 24, 2022 22:27
Copy link
Contributor

@andrewetchen andrewetchen left a comment

Choose a reason for hiding this comment

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

  • You can try and load main locally, remove the dynamic checkout button and go to the Test 3D models, video product which is showing on the home page and feat. collection, using lighthouse in the inspect tool. Test for mobile and desktop.
  • Then do the same thing on this test theme/branch to compare the results.
  • Test other products to make sure it hasn't impacted in any way their performance.

The score improved by roughly the same margin that your referenced in your screenshots. I tested on desktop and mobile and compared the latest main against your branch 👍🏼

@ludoboludo ludoboludo merged commit 2e5cd36 into main Feb 25, 2022
@ludoboludo ludoboludo deleted the cls-fix-main-product branch February 25, 2022 14:25
phapsidesGT pushed a commit to Gravytrain-UK/gt-shopify-dawn-theme that referenced this pull request Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cumulative Layout Shift on product page when using portrait 9:16 product pics
3 participants