Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to adjust gatsby-image lazy loading threshold #14103

Closed
FraserThompson opened this issue May 17, 2019 · 6 comments
Closed

Add ability to adjust gatsby-image lazy loading threshold #14103

FraserThompson opened this issue May 17, 2019 · 6 comments
Labels
stale? Issue that may be closed soon due to the original author not responding any more.

Comments

@FraserThompson
Copy link
Contributor

Summary

I would like to be able to change the "threshold" before an image is loaded. So instead of loading the image as soon as it enters the viewport, I'd like this to be configurable so more images are loaded.

Motivation

I use gatsby-image in an image gallery which can have up to 60 or so photos, displayed in a single column on mobile.

Lazy loading is obviously essential to ensure all 60 aren't downloaded at once, but scrolling through the images isn't a nice experience when you have to wait a second or so for each image to load as soon as it enters the viewport. If we could configure the threshold to load more images before the user gets to them it would improve the experience for users.

@m-allanson
Copy link
Contributor

Thanks for opening this @FraserThompson! There's been a few bits of discussion around this in the past. Check out the comments on this PR #13816 (comment)

To summarise the discussion there - we're moving towards letting the browser handle this natively and currently we don't want to add an option that makes the threshold configurable. However we would be interested in seeing research that identifies a better default value - the current value is 200px.

Do you have a link to your gallery? That might be a good example case where the existing threshold doesn't work well.

@FraserThompson
Copy link
Contributor Author

Oh sorry, I did do a search but somehow missed that PR...

Here's the gallery I'm talking about: https://dunedinsound.com/gigs/primitive-man---dunedin/

It works okay on desktop but for a user scrolling through relatively quickly on mobile to get a good look at all the images the loading lags behind at some points.

@KyleAMathews
Copy link
Contributor

Could you try upgrading the distance to e.g. 350px see how big of difference that makes?

@polarathene
Copy link
Contributor

There are plans to refactor gatsby-image functionality to be more composable for v3 of Gatsby. That will allow you to use the default, or alter/swap certain behaviour more easily for more niche needs.

Presently, you could consider something like react-waypoint, having it trigger critical / loading="eager" props to opt-out of lazy-load for n images?

but for a user scrolling through relatively quickly on mobile to get a good look at all the images the loading lags behind at some points.

I don't think much can be done about that regarding scrolling quickly. All images prior will be still queued up to download, the browser may lower the priority to focus on those in/near the viewport though. You could consider a virtualized list component, that would remove the images further away from the view which should cancel the browser downloading them, allowing for the images in the users view and near it to be prioritized.

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jun 9, 2019
@gatsbot
Copy link

gatsbot bot commented Jun 9, 2019

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contributefor more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@gatsbot
Copy link

gatsbot bot commented Jun 20, 2019

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community!

@gatsbot gatsbot bot closed this as completed Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more.
Projects
None yet
Development

No branches or pull requests

4 participants