-
Notifications
You must be signed in to change notification settings - Fork 41
Add RFC for adding support for prefetching critical images #35
base: master
Are you sure you want to change the base?
Conversation
Some notes I hope help with the design:
|
@addyosmani thanks for the notes! I wrote up one possible work around for prefetches lack of persistence at gatsbyjs/gatsby#12800 |
We can't rely on people having SW available and in any case, we want prefetching to always low priority which is only easily achieved right now with |
Another related optimization this RFC will enable — we use the IntersectionObserver API to lazy load images. Because loading images is a heavy operation (both bandwidth & CPU to render it on the client) we don't start loading the image until the user has scrolled close to the image. But this isn't ideal as it means that on slower connections or if the user is scrolling fast, that images will be delayed in displaying as the browser won't be able to download them fast enough. Prefetching images is a pretty light-weight way to get ahead of things as it won't block anything else. So we could add another IntersectionObserver that watches much further ahead and starts prefetching images ahead of time. This would again contribute to making Gatsby sites appear quick and smooth. |
We'd probably put the image prefetching code into its own package e.g. |
cc @jlengstorf re: per-page MDX and shortcodes discussion. |
rendered text