Archived topic
CLS issue: more than 0.25 (mobile)
14 replies · Started by ustar on July 13, 2020
Hi, GP team!
I have noticed that my site has problem "CLS issue: more than 0.25 (mobile)" in GSC.
All of product pages only.
All Typography settings are in "System Stack" Font family already long time.
What else i can do to fix this issue?
Thanks in advance!
Regards, Sergey.
... and can it be due the logo size in the Customizing/Layout/Header/Logo?
I have now 125x125 pixels.
What size of this logo do you recommend to use?
Thanks. Sergey.
Hi there,
its most likely the lazy loader. Can you exclude the logo images from the lazyloader ?
I put image link
https://u-star.cz/favicon_u-star_eshop_black_circle-2/
to the Lazy-load exclusions in the Autoptimize Settings.
Did i all correct?
How to check that it will help?
Can you disable the lazy load option in Autoptimize. Then let me know
Done.
Ok so that proves the logo lazy load is a problem.
Add this PHP Snippet to your site.
add_filter( 'generate_mobile_header_logo_output', function( $output ) {
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
return $output;
}
$settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
return sprintf(
'<div class="site-logo mobile-header-logo">
<a href="%1$s" title="%2$s" rel="home">
<img src="%3$s" class="no-lazy" alt="%4$s" />
</a>
</div>',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
esc_url( apply_filters( 'generate_mobile_header_logo', $settings['mobile_header_logo'] ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
);
} );
Then in Autoptimize you can add the no-lazy class to exclude the logo.
I added the code to the functions.php of the child theme and added no-lazy to the Lazy-load exclusions in the Autoptimize Settings. Am i correct?
Yes, thats correct. And that code is working. And your CLS is scores is reporting 0
Thank you very much, David!
Cool!
But after that images on pages with products listing are not showing.
I could give you a permition to the admin section if you need to check.
Regards, Sergey.
* on mobile devices only. Sorry, i forgot to write this.
I removed no-lazy from Autoptimize, saved settings, added again and saved again.
Please, check from your side, is it ok now or not.
Thanks.
Sergey.
Logo and images are all working for me :)
Thanks, David!
You're welcome