summaryrefslogtreecommitdiff
path: root/packages/integrations/prefetch/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations/prefetch/README.md')
-rw-r--r--packages/integrations/prefetch/README.md24
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/integrations/prefetch/README.md b/packages/integrations/prefetch/README.md
index 4dab2121b..9a061fc2a 100644
--- a/packages/integrations/prefetch/README.md
+++ b/packages/integrations/prefetch/README.md
@@ -56,6 +56,8 @@ export default defineConfig({
When you install the integration, the prefetch script is automatically added to every page in the project. Just add `rel="prefetch"` to any `<a />` links on your page and you're ready to go!
+In addition, you can add `rel="prefetch-intent"` to any `<a />` links on your page to prefetch them only when they are hovered over, touched, or focused. This is especially useful to conserve data usage when viewing your site.
+
## Configuration
The Astro Prefetch integration handles which links on the site are prefetched and it has its own options. Change these in the `astro.config.mjs` file which is where your project's integration settings live.
@@ -80,6 +82,28 @@ export default defineConfig({
});
```
+### config.intentSelector
+
+By default, the prefetch script also searches the page for any links that include a `rel="prefetch-intent"` attribute, ex: `<a rel="prefetch-intent" />`. This behavior can be changed in your `astro.config.*` file to use a custom query selector when finding prefetch-intent links.
+
+__`astro.config.mjs`__
+
+```js
+import { defineConfig } from 'astro/config';
+import prefetch from '@astrojs/prefetch';
+
+export default defineConfig({
+ // ...
+ integrations: [prefetch({
+ // Only prefetch links with an href that begins with `/products` or `/coupons`
+ intentSelector: ["a[href^='/products']", "a[href^='/coupons']"]
+
+ // Use a string to prefetch a single selector
+ // intentSelector: "a[href^='/products']"
+ })],
+});
+```
+
### config.throttle
By default the prefetch script will only prefetch one link at a time. This behavior can be changed in your `astro.config.*` file to increase the limit for concurrent downloads.