Replies: 4 comments 1 reply
-
|
Sounds great! I think there should also be an opt-out per link if you have |
Beta Was this translation helpful? Give feedback.
-
|
I like that very much! Fine-grained control for users solves all the problems we currently have with fully automated fetch-them-all. |
Beta Was this translation helpful? Give feedback.
-
|
I updated the description to include "programmatic usage": |
Beta Was this translation helpful? Give feedback.
-
|
Closing as the stage 3 RFC has been merged. Thanks everyone for chiming in! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Body
Summary
Deprecate
@astrojs/prefetchand provide first-class prefetch support in Astro.Initial implementation: withastro/astro#8951
Background & Motivation
With the introduction of View Transitions, it includes partial prefetching code for snappy navigation between pages. We can take this opportunity to support prefetching in core, and share the prefetch behaviour with View Transitions.
I've started an implementation before an RFC as the initial plan was to simply move
@astrojs/prefetchto core. However, it would also be a good time to polish up and extend the API.Similar discussion: #661
Goals
Example
Based on the implementation currently (withastro/astro#8951), the usage looks like this:
You can also configure options in
astro.config.js:Boolean options also work:
Different prefetch strategies have different behaviours and opinions:
tap: Callsfetch()ontouchstartormousedownevents (they are called beforeclickevent)hover: Callsfetch()onfocusin+focusoutormouseenter+mouseleaveevents. Hover detection kicks in after 80ms delay.viewport: Creates a<link rel="prefetch">on enter viewport. It has lower priority thanfetch()to not clog up the request. Intersection detection kicks in after 300ms.Notes:
hoverandviewportonly works on<a />tags on initial page load (and view transition page load) due to limitations of the events. Unless we watch the entire DOM with MutationObserver but it's not performant.For programmatic usage, we can also support:
Beta Was this translation helpful? Give feedback.
All reactions