Skip to content

Commit 01ee0d0

Browse files
Marocco2sarah11918
andauthored
Apply suggestions from code review
Co-authored-by: Sarah Rainsberger <[email protected]>
1 parent 2bc9106 commit 01ee0d0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

.changeset/poor-squids-like.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
'astro': minor
33
---
44

5-
Add `eagerness` support for `prefetch()`
5+
Adds a new `eagerness` option for `prefetch()` when using `experimental.clientPrerender`
66

7-
With [`clientPrerender`](https://docs.astro.build/en/reference/experimental-flags/client-prerender/) experiment enabled, you can use `eagerness` option, following the same API described in [Speculation Rules API](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/speculationrules#eagerness).
7+
With the experimental [`clientPrerender`](https://docs.astro.build/en/reference/experimental-flags/client-prerender/) flag enabled, you can use the `eagerness` option on `prefetch()` to suggest to the browser how eagerly it should prefetch/prerender link targets.
88

9-
For example, you have a set of links that you want to be prerendered/prefetched but there are too many for browsers to handle (Chrome have some [limits in place](https://developer.chrome.com/blog/speculation-rules-improvements#chrome-limits)).
10-
To prevent that, you can set `eagerness: 'moderate'` to get advantage of FIFO strategies and browser heuristics to let it decide when prerender/prefetch them and in what order.
9+
This follows the same API described in the [Speculation Rules API](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/speculationrules#eagerness) and allows you to balance the benefit of reduced wait times against bandwidth, memory, and CPU costs for your site visitors.
10+
11+
For example, you can now use `prefetch()` programmatically with large sets of links and avoid [browser limits in place to guard against over-speculating](https://developer.chrome.com/blog/speculation-rules-improvements#chrome-limits) (prerendering/prefetching too many links). Set `eagerness: 'moderate'` to take advantage of [First In, First Out (FIFO)](https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics)) strategies and browser heuristics to let the browser decide when to prerender/prefetch them and in what order:
1112

1213
```astro
1314
<a class="link-moderate" href="/nice-link-1">A Nice Link 1</a>

0 commit comments

Comments
 (0)