3

I configured my .htaccess to lazyload images using mod_pagespeed, but I don't want to affect the user experience by showing an image that is not loaded yet.

Is there a way to set a configuration and lazyload images some pixels before they become visible in the viewport using mod_pagespeed?

Zeno Rocha
  • 3,226
  • 1
  • 23
  • 27

2 Answers2

5

If you enable image lazy-loading in mod_pagespeed, the default behavior is to load images on "on scroll". We do have existing code paths to change this to "onload" - aka, load images after onload has fired, but unfortunately we haven't yet exposed it as a configuration flag. A feature for one of the upcoming releases! :-)

Current filter documentation: https://developers.google.com/speed/docs/mod_pagespeed/filter-lazyload-images

igrigorik
  • 9,433
  • 2
  • 29
  • 30
  • Thanks Ilya, actually it's ok to load images on "on scroll", I just wanted to define a number of pixels before this image to load. For example if my image is at 700px from the top, I don't it to start loading when it hits my viewport. I wanted to load it when my viewport is at 600px from the top. Then, when the user reaches 700px it's already loaded. You should really expose this config flag :) – Zeno Rocha Mar 08 '13 at 01:14
1

Unfortunately, there is no current way to add an "offset" to when lazyload starts loading the image. It's currently set to the bottom of the viewport, and no option is exposed to configure this. However, I think this would be a valuable option to expose, and I've recorded your feature request at https://code.google.com/p/modpagespeed/issues/detail?id=644.

Jud
  • 552
  • 4
  • 9