diff --git a/.changeset/cold-shoes-drum.md b/.changeset/cold-shoes-drum.md new file mode 100644 index 000000000000..b087ebc9922a --- /dev/null +++ b/.changeset/cold-shoes-drum.md @@ -0,0 +1,5 @@ +--- +"@astrojs/prefetch": patch +--- + +Use `passive` event listeners for performance diff --git a/packages/integrations/prefetch/src/client.ts b/packages/integrations/prefetch/src/client.ts index 02661bb9d68c..187c808cb7bd 100644 --- a/packages/integrations/prefetch/src/client.ts +++ b/packages/integrations/prefetch/src/client.ts @@ -25,7 +25,7 @@ let observer: IntersectionObserver; function observe(link: HTMLAnchorElement) { preloaded.add(link.href); observer.observe(link); - events.map((event) => link.addEventListener(event, onLinkEvent, { once: true })); + events.map((event) => link.addEventListener(event, onLinkEvent, { passive:true, once: true })); } function unobserve(link: HTMLAnchorElement) {