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

Lazy load for gatsby-remark-images #15716

Closed
humphreybc opened this issue Jul 15, 2019 · 5 comments · Fixed by #16448
Closed

Lazy load for gatsby-remark-images #15716

humphreybc opened this issue Jul 15, 2019 · 5 comments · Fixed by #16448
Labels
help wanted Issue with a clear description that the community can help with.

Comments

@humphreybc
Copy link
Contributor

humphreybc commented Jul 15, 2019

Summary

Out of the box, Gatsby does a good job of lazy loading images below the fold through gatsby-image. However, gatsby-remark-images doesn't appear to do this, which results in “Defer offscreen images” complaints from Lighthouse when testing a Markdown-generated page.

It would be nice if gatsby-remark-images added lazy loading so that images below the fold are not loaded until the user scrolls down the page. Bonus points if support for the new Chrome native lazy loading API was extended to gatsby-remark-images too.

Previous work

There's been an attempt to add lazy-loading to gatsby-remark-images in this plugin. However it doesn't seem to work very well, and requires an external dependency in lazysizes. It would be better if this functionality was built into gatsby-remark-images like it is with gatsby-image.

Another relevant issue: #2288

Motivation

Improve the performance for Markdown-generated pages.

@sidharthachatterjee
Copy link
Contributor

Thank you for opening this @humphreybc

We'd love to accept a pull request porting the lazy load implementation over to gatsby-remark-images

Marking this as help wanted for the moment!

@sidharthachatterjee sidharthachatterjee added the help wanted Issue with a clear description that the community can help with. label Jul 15, 2019
@humphreybc
Copy link
Contributor Author

@sidharthachatterjee If you could drop a link to the relevant code in gatsby-image, I could take a look and see how difficult it would be to port to gatsby-remark-images. The Chrome stuff is just adding an attribute to the HTML tag, so that should be pretty easy.

@marcel0ll
Copy link

marcel0ll commented Jul 16, 2019

@humphreybc have a look at gatsby-image, it uses IntersectionObserver to 'defer image loading'.

gatsby-image
mdn:IntersectionObserver

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

gatsbot bot commented Aug 6, 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! 💪💜

@karlhorky karlhorky added not stale and removed stale? Issue that may be closed soon due to the original author not responding any more. labels Aug 7, 2019
@sidharthachatterjee
Copy link
Contributor

sidharthachatterjee commented Aug 11, 2019

gatsby-remark-images@3.1.10 supports native lazy loading thanks to @gabefromutah 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issue with a clear description that the community can help with.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants