Skip to content

Commit

Permalink
tap fallback and ignore slow connection
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtimsb committed Nov 13, 2023
1 parent 5ce13aa commit ef578b4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/content/docs/en/guides/prefetch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ You can specify a strategy for an individual link by passing it to the `data-ast

Each strategy is fine-tuned to only prefetch when needed and save your users' bandwidth. For example:

- If a visitor is using [data saver mode](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/saveData) or has a [slow connection](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/effectiveType), prefetching will be turned off.
- If a visitor is using [data saver mode](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/saveData) or has a [slow connection](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/effectiveType), prefetch will fallback to tap strategy.
- Quickly hovering or scrolling over links will not prefetch them.
- Links that use the `viewport` strategy are prefetched with a lower priority to avoid clogging up the network.

Expand Down Expand Up @@ -116,6 +116,13 @@ prefetch('/about', { with: 'link' });

The `prefetch()` API includes the same [data saver mode](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/saveData) and [slow connection](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/effectiveType) detection, so that it only prefetches when needed.

To ignore slow connection detection, you can use `ignoreSlowConnection` option:

```js
// Prefetch even on data saver mode or slow connection
prefetch('/about', { ignoreSlowConnection: true });
```

Make sure to only import `prefetch()` in client-side scripts as it relies on browser APIs.

## Using with View Transitions
Expand Down

0 comments on commit ef578b4

Please sign in to comment.