2

The problem: PageSpeed Insights says images aren't being lazy loaded and the documentation says the img tag should be replaced with "data-pagespeed-lazy-src" attribute (its not doing that).

pagespeed.conf:

...
ModPagespeedEnableFilters lazyload_images
..

HTML rendered:

<img width="100%" height="100%" src="/img/xstrategy_creation.png.pagespeed.ic.3BVepnuhcw.webp" data-pagespeed-url-hash="3308235655" onload="pagespeed.CriticalImages.checkImageForCriticality(this);">

It's converting the png image and I see the "X-Mod-Pagespeed" header so I'm sure the module is there.

/pagespeed_admin shows that "Lazyload Images" filter is enabled. The onload javascript resource also looks like its attaching.

It seems like its half working (attaching the javascript onload to detect if the image is above the fold). I tried refreshing the page a bunch and giving it time, nothing ever changes. Image is below the fold.

I've purged the cache and still get this result.

Even the example given by pagespeed documentation doesn't seem to work: https://www.modpagespeed.com/examples/lazyload_images.html?ModPagespeed=on&ModPagespeedFilters=lazyload_images

Brayden Hancock
  • 786
  • 1
  • 6
  • 22

1 Answers1

0

mod_pagespeed's lazyloading filter needs to be instrumented. That happens by page loads sending it beacons. So if you refresh the browser a couple of times, eventually you will see the final results. Until that happens unoptimized or partially optimized responses will be emitted.

oschaaf
  • 281
  • 1
  • 7
  • 1
    "I tried refreshing the page a bunch and giving it time, nothing ever changes. Image is below the fold." Also src attribute is suppose to be replaced (which isn't happening). And the example they give (which I assume has also gone through time to be instrumented) doesn't work. – Brayden Hancock May 09 '19 at 20:58
  • Well, I just checked, and I do see src being replaced data-pagespeed-lazy-src for the below the fold images of the example. So I'm not sure what is up. What browser are you testing with? – oschaaf May 12 '19 at 19:47
  • Mac chrome and safari. I also tried on my windows pc (chrome). I noticed when refreshing I see that new src attribute (at least I think, its replaced very quickly) but then it's replaced to src. – Brayden Hancock May 13 '19 at 20:59