From ef578b40d0f7135a5f7f5bfe2610791773375100 Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Tue, 14 Nov 2023 01:59:35 +0530 Subject: [PATCH] tap fallback and ignore slow connection --- src/content/docs/en/guides/prefetch.mdx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/content/docs/en/guides/prefetch.mdx b/src/content/docs/en/guides/prefetch.mdx index c831434d63e10..c540cc7ed7c56 100644 --- a/src/content/docs/en/guides/prefetch.mdx +++ b/src/content/docs/en/guides/prefetch.mdx @@ -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. @@ -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