Site logo

Archived topic

Poor CLS scores when using Videp or YouTube elements in Gutenberg

24 replies · Started by Mark on June 1, 2022

Viewing posts 1–15 of 25

Hi there,

We're in the process of moving to Generatepress in order to try and improve CWV.

We are getting high CLS scores when embedding YouTube videos using either the YouTube or Video elements in Gutenberg (we are running the latest version of GP & Premium).

However, the number drops to almost zero if we use the "custom HTML" element and embed with an iframe. This good score similar to the number on the live page which does not use GP.

Here is the report: https://rb.gy/gfae4t

We prefer to use the YouTube or Video element as that is what we do on another GP site (and we have no issues there). We prefer not to mess around with the dimensions in Custom HTML.

Thanks for your help :)

Hi Fernando,

This didn't work (I also set to 43 minimum height in the container).

Mark

I would be interested to see where this goes as well.

Mark - do you typically insert 1 you tube video per blog?

Hi Derek,

Yes. Sometimes two. I'm testing on pages with just the 1 video though.

I'd prefer to use the youtube player Gutenberg element as that's foolproof to use. Having to use iframes means we have to manually play with size ratios and it gets messy

Hi Mark,

Yes, I am currently adding 2 videos as well. I would be interested to see how you get this fixed as I am looking for the same solution. I always thought the embed function was ok to use. How sure are you that it is these embedded videos that are causing CLS issues?

Have you tried adding a lazy load plugin that only loads the videos as the user gets to them?

Embedding actually works (embedding iframes), it's the YT player in Gutenberg that is giving issues

Hi Fernando,

Keeping the YouTube block and switching off "resize for smaller devices" has dropped the desktop CLS right down, and slightly reduced the CLS for mobile to 0.355.

It needs to be close to zero or 0.02 as per the live version.

I then put the YT block into a container and the CLS went up to 1.3 seconds (with "Resize for smaller devices" on).

Then, with the YT block still in the container (with "Resize for smaller devices" switched to off), the CLS went back down to 0.355 again

I have left the page like this.

It seems that to container makes no difference.

Hi there,

when i check the Page Speed Insight report you provided above, the main CLS issue i see is related to Logo.
The Logo is being lazy loaded and optimized by Shortpixel which looks to be messing with its size. Best to exclude logos from that process. Most image optim plugins allow you to exclude imgs with a specific CSS class. For all the GP logos you can use is-logo-image

If you can fix that first then we can revisit the video i necessary.

Hi David,

I added the image in after my last comment. I appreciate the feedback though. We're working on not lazy-loading the image.

Note I've run more tests and the CLS for the pages is exactly the same as it was before I added the logo.

I'm going to finish off the redesign work to help stop any potential conflict in optimisation work. Will ping back when I'm finished (in the next day or two).

Thanks

Ok - we'll be here :)

Hi David,

I've completed most of the theme setup now. The logo has also been omitted from lazy-load.

The CLS is poor on all pages regardless of video, although video pages are much worse. In fact all metrics are poorer than what I was expecting.

I've created a similar home page to the live version. The live site

There are the URLs I'm looking at are in the private section.

For comparison, here is another site on GeneratePress which has been set up fairly similarly (in the private section) The metrics are good for this site.

Hope you can help

Thanks,
Mark

Hi Mark,

I tried viewing your site with and without WP Rocket to check if the CLS is being caused by a setting you have in WP Rocket.

Screen recording with WP Rocket: https://share.getcloudapp.com/Wnu7EzO7

Without: https://share.getcloudapp.com/5zurJWQ5

As shown in the videos, the CLS seems to be coming from a setting in WP rocket.

Can you try disabling settings that optimize CSS for instance in WP rocket and see how it goes? Are you merging CSS?

Hope to hear from you soon.

I don't believe we do. The Combine CSS Files (Combine CSS merges all your files into 1, reducing HTTP requests. Not recommended if your site uses HTTP/2) is unchecked.

I'll test settings and get back to you once I get confirmation on aspects from WP Rocket support.

This archived topic is closed to new replies.