Skip to content

Frank Goossens' blog

  • Web-Tech blogposts
  • Other blogposts
  • WordPress & plugins
    • WP YouTube Lyte
    • Autoptimize
    • WP DoNotTrack
    • Do Not Donate!
  • about
    • Timemachine
    • Contact

featured image

AO not lazyloading above the fold; the sequel

December 23, 2020 by futtta

So in the ever-continuing saga of learning, testing and fine-tuning your site’s settings to get the ultimate in performance you might have enjoyed the new Autoptimize filter/ setting not to lazyload the first N images to keep the impact of lazyloading on Largest Contentfull Paint down?
Well, now you can take things a step further with below code snippet, which tells Autoptimize not to lazyload the logo and the featured image (hat tip to Gijo Varghese of Flying Press for the idea).

add_filter('autoptimize_filter_imgopt_lazyload_exclude_array', function( $lazy_excl ){
	// site logo.
	$custom_logo_id = get_theme_mod( 'custom_logo' );
	$image = wp_get_attachment_image_src( $custom_logo_id , 'full' );
	$logo = $image[0];
	if ( ! empty( $logo ) ) {
		$lazy_excl[] = $logo;
	}
	// featured image.
	if ( is_single() || is_page() ) {
		$featured_img = get_the_post_thumbnail_url();
		if ( ! empty( $featured_img ) ) {
			$lazy_excl[] = $featured_img;
		}
	}
	return $lazy_excl;
});

This might end up in a future version of Autoptimize, maybe even preloading those images … 🙂

Categories autoptimize, lang:en, wordpress Tags code snippet, featured image, lazyload, logo, not lazyload, preload 3 Comments

Autoptimize user? Speed up your site even more with AO Pro, use futttablog coupon code to get a 10% discount!

  • subscribe to my web-tech blogfeed
  • abonneer op niet-technische artikels
  • fediverse: @frank@blog.futtta.be
  • @futtta on the fediverse (mastodon)
This is an ad-free blog!

You said, she said

  1. Nic3 🇪🇺 on PISA; minder lezen gaat verder dan onderwijs alleen
  2. Ingrid Hoeben Ⓥ 🇧🇪 on PISA; minder lezen gaat verder dan onderwijs alleen
  3. frank goossens 🇧🇪🇪🇺 on PISA; minder lezen gaat verder dan onderwijs alleen
  4. Vastmans 🌈🌱 on PISA; minder lezen gaat verder dan onderwijs alleen
  5. #maatschappij on PISA; minder lezen gaat verder dan onderwijs alleen

Recent Blogposts

  • PISA; minder lezen gaat verder dan onderwijs alleen
  • Teken je de petitie voor burgerpanels in België?
  • Flying high on the bicycle
  • 10 jaar Boekenjagers!
  • Gelezen; “Schaduwleven” van Jaap Robben
© 2026 Frank Goossens' blog • Built with GeneratePress