[Support request] SVG causing CLS movement

Home Forums Support [Support request] SVG causing CLS movement

Home Forums Support SVG causing CLS movement

Viewing 15 posts - 1 through 15 (of 30 total)
  • Author
    Posts
  • #1539227
    William

    Hi there,

    I uploaded an SVG logo for my site here. Since loading, I notice there is a CLS movement of the logo going from big to small – why is this the case with such a SVG logo on Generate Press and can it be fixed please?

    Kind regards,

    Will

    #1539264
    Leo
    Staff
    Customer Support

    Hi there,

    Can you test if the issue is resolved when WP Rocket is disabled?

    I think it’s a lazy loading issue.

    #1539294
    William

    I’ve disabled WP Rocket and EWWWW image optimizer and the issue still persists.

    #1539337
    Leo
    Staff
    Customer Support

    Can you disable WP Rocket so I can run the site through PageSpeed Insight and try to determine the issue?

    #1539385
    William

    Sure thing, deactivated

    #1539496
    Leo
    Staff
    Customer Support

    I’m still seeing WP Rocket activated.

    Can you confirm?

    #1543188
    William

    Sure, it is deactivated

    #1543703
    David
    Staff
    Customer Support

    Hi there,

    first try excluding the Logo image from being lazy loaded by adding this PHP Snippet to your site:

    function rocket_lazyload_exclude_class( $attributes ) {
    	$attributes[] = 'class="is-logo-image"';
    
    	return $attributes;
    }
    add_filter( 'rocket_lazyload_excluded_attributes', 'rocket_lazyload_exclude_class' );
    #1543900
    William

    Hi there,

    I had deactivated WP Rocket and the issue still persists – added the above but has nad no impact.

    #1544019
    David
    Staff
    Customer Support

    Some other plugin or the litespeed cache is lazyloading the image.
    Can you disable whatever else may be adding lazyload to test if thats the issue.

    #1544551
    William

    I’ve disabled all plugins that could cause this and the issue persists

    #1544595
    David
    Staff
    Customer Support

    First try removing the Retina version of the image, this is not required for SVG and can be one cause.

    If still an issue try changing the Customizer > General –> Structure to Flexbox.

    #1544802
    William

    This unfortunately does not seem to make much difference – removed the retina logo and changed structures

    #1545284
    Elvin
    Staff
    Customer Support

    Hi,

    Consider adding fixed width and height attribute to your logo <img>.

    You can change the markup of your logo to add attributes by using this filter: https://docs.generatepress.com/article/generate_logo_output/

    For example:

    add_filter( 'generate_logo_output', 'tu_logo_attributes', 10, 3 );
    function tu_logo_attributes( $output, $logo_url, $html_attr ) {
    	printf(
    		'<div class="site-logo">
    			<a href="%1$s" title="%2$s" rel="home">
    				<img %3$s width="235" height="100" />
    			</a>
    		</div>',
    		esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
    		esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
    		$html_attr
    	);
    }

    Here’s how to add PHP – https://docs.generatepress.com/article/adding-php/

    #1546896
    William

    Thank you – that seems to stop the logo going large to small – however, the CLS issue of the logo still exists – this time, when on load, the logo not being there causes the header to be a certain height, and then to increase in height when the image loads.

    I think this could be fixed with CSS to make header on desktop a certain height, can you provide please?

Viewing 15 posts - 1 through 15 (of 30 total)
  • You must be logged in to reply to this topic.