Gatsby: Lazy load for gatsby-remark-images

Created on 15 Jul 2019  ·  5Comments  ·  Source: gatsbyjs/gatsby

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: https://github.com/gatsbyjs/gatsby/issues/2288

Motivation

Improve the performance for Markdown-generated pages.

help wanted

Most helpful comment

[email protected] supports native lazy loading thanks to @gabefromutah 🥇

All 5 comments

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 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.

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

gatsby-image
mdn:IntersectionObserver

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! 💪💜

[email protected] supports native lazy loading thanks to @gabefromutah 🥇

Was this page helpful?
0 / 5 - 0 ratings

Related issues

totsteps picture totsteps  ·  3Comments

andykais picture andykais  ·  3Comments

3CordGuy picture 3CordGuy  ·  3Comments

ferMartz picture ferMartz  ·  3Comments

brandonmp picture brandonmp  ·  3Comments