• Google PageSpeed insights is suggesting I lazy load the images that are used as thumbnails with WP Youtube Lyte.

    I lazy load images using autoptimize, is it possible to get this to work with this plugin or have this plugin lazy load the images?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    I think there’s a topic on this here somewhere with a solution outdoorsdev1, but it does require some code. To be honest; although GPSI might not see it, the images are in fact loaded late aka lazy (do a test on webpagetest and you’ll the the are loaded after domcontentloaded has fired) so I would not bother really ??

    Thread Starter outdoorsdev1

    (@outdoorsdev1)

    They are loaded late in the order so they aren’t content blocking – which is good.

    However I’d prefer them not to load at all unless scrolled into view. This would be a killer feature as speed is the main reason I use this plugin. I’ve got a popular post that has 6 or 7 yt vids, and losing about 350kb of images from the initial page load would be really helpful.

    Was this code from this thread what you were referencing?

    add_filter('lyte_match_postparse_template','lyte_bgimg');
    function lyte_bgimg($in) {
    	return preg_replace('/(<div id="lyte_[^"]*"\s)data-src="([^"]*)"/', '\1 style="background-image:url(\'\2\')" ', $in);
    }

    https://www.ads-software.com/support/topic/store-local-thumbnails-with-name-of-video-id/

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    that’s the one, yeah.

    re AO’s lazy-loading: it uses lazysizes, which does load all images as well even when not in view, more info at https://github.com/aFarkas/lazysizes

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Lazy load images’ is closed to new replies.