GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add RFC for adding support for prefetching critical images by KyleAMathews · Pull Request #35 · gatsbyjs/rfcs

This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Conversation

@KyleAMathews

@KyleAMathews KyleAMathews commented Mar 23, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

rendered text

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

brotzky, matijagrcic, and totsteps reacted with thumbs up emoji arcticicestudio, totsteps, and ooloth reacted with hooray emoji brotzky and arcticicestudio reacted with heart emoji
All reactions
  • 👍 3 reactions
  • 🎉 3 reactions
  • ❤️ 2 reactions
KyleAMathews added 2 commits March 22, 2019 20:00
@KyleAMathews
Add RFC for adding support for prefetching critical images
ba93543
@KyleAMathews
Add date
1a44c07
@addyosmani

addyosmani commented Mar 24, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Some notes I hope help with the design:

  • If a resource in Chrome is prefetched with <link rel=prefetch>, it will be fetched at a low priority and kept around in the memory cache for 5 minutes. This lasts until the resource has been consumed, at which point the normal cache-control rules for the resource will apply. If Gatsby plans to use prefetch for images in addition to full HTML responses we might want to be careful that these resources will be used in the first few minutes.
  • Prefetching can also mostly be accomplished using Service Workers (precaching). The difference here is you're persisting resources to the disk/Cache API which means it doesn't matter if the user fails to use the resource in that 5m limit. It does require that SWs are used however.
  • SW fetches, unlike with rel=prefetch, are performed at a higher rather than lower network priority so care must be taken with the "when" do you fetch. You don't want to contend with important fetches for other content on the current page. Priority Hints will give you a way to fetch with importance=low, but are in Origin Trials at the moment.
  • In the future if Priority Hints do land, we might want to explore Gatsby using importance=high or low on images.
DSchau and Asjas reacted with heart emoji
All reactions
  • ❤️ 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@KyleAMathews KyleAMathews mentioned this pull request Mar 24, 2019
<link rel="prefetch"> downloads aren't persisted as expected — use XHR to save gatsbyjs/gatsby#12800
Closed
@KyleAMathews

KyleAMathews commented Mar 24, 2019

Copy link
Copy Markdown
Contributor Author

@addyosmani thanks for the notes! I wrote up one possible work around for prefetches lack of persistence at gatsbyjs/gatsby#12800

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@KyleAMathews

KyleAMathews commented Mar 24, 2019

Copy link
Copy Markdown
Contributor Author

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 <link prefetch>

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@KyleAMathews

KyleAMathews commented Mar 24, 2019

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@KyleAMathews

KyleAMathews commented Mar 24, 2019

Copy link
Copy Markdown
Contributor Author

We'd probably put the image prefetching code into its own package e.g. prefetch-image which takes an object with the src/srcset strings and starts the prefetching.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@KyleAMathews KyleAMathews mentioned this pull request Mar 28, 2019
refactor(gatsby): enable running of static/page queries separately gatsbyjs/gatsby#12891
Closed
@ChristopherBiscardi

ChristopherBiscardi commented May 9, 2019

Copy link
Copy Markdown

cc @jlengstorf re: per-page MDX and shortcodes discussion.

jlengstorf reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced May 15, 2019
Add a <link preload rel="image"> for each "critical" image (when using gatsby-image) gatsbyjs/gatsby#14043
Closed
[BUG]: gatsby-image cache key is not reliable if viewport resizes gatsbyjs/gatsby#14073
Closed
@KyleAMathews KyleAMathews mentioned this pull request Jun 10, 2019
Per page manifest gatsbyjs/gatsby#14359
Merged
@pieh pieh mentioned this pull request Nov 2, 2019
Manual code-splitting gatsbyjs/gatsby#18689
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@KyleAMathews @addyosmani @ChristopherBiscardi
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.