Closed (fixed)
Project:
Easy Responsive Images
Version:
1.4.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
1 May 2024 at 09:33 UTC
Updated:
1 Aug 2025 at 13:14 UTC
Jump to comment: Most recent
Currently there's no threshold on the intersection observer, so images get loaded as they enter the viewport.
This causes a short delay before the image is visible.
When using <img loading="lazy"> images start loading when they get near the viewport so they're more likely to have finished loading by the time they enter the viewport.
Edit: seems like the threshold is 300px. On Chrome it's 1250px for fast connections and 2500px for slower connections.
Change the threshold to be more similar to the native value.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
kubrick commentedComment #3
kubrick commentedComment #4
kubrick commentedComment #6
kubrick commentedComment #7
seanbThis seems to make sense! Thanks for the issue. I will check the PR this week and try to get this in.
Comment #8
smustgrave commentedReading the article on https://web.dev/articles/browser-level-image-lazy-loading#distance-from-... this appears to make sense.
Comment #9
seanbLooking at this again, I guess this is a tradeoff between initial loading times and perceived performance while scrolling.
Could we maybe make this configurable with a link to https://web.dev/articles/browser-level-image-lazy-loading#distance-from-... in the settings page? I would be happy to default to what chrome does, but I can think of some cases for media rich sites where you might want a smaller offset.
Comment #10
kubrick commentedI'd be ok with making it configurable. Which way should be the default behavior?
The current configuration for the module links to "Generate image styles" page, adding the option there feels out of place to me.
While making it part of the display config might make it too granular - I'd think I'd prefer it to be a global setting.
Comment #11
seanbI agree this should be a global setting. Added this to the config page we have right now is a bit weird, but I guess I can live with that.
The default should be what chrome does. I don't think this is something lots of people think about. I just know at least 1 example of a site that I would like to have a lower default for performance, so that is why I chose 300 in the first place :)
We should have an update hook to set it to our new default, for the example site I would want a lower default for, I can change it manually.
Comment #14
kubrick commentedComment #15
seanbThanks for the changes, this looks good! I will try to test it shortly. If other people can check this out and RTBC that would also help!
Comment #16
smustgrave commentedLeft some review comments.
Comment #17
kubrick commentedComment #18
seanbMerged, thanks!
Comment #19
seanbFixed issue credits.