Use passive listeners in prefetch (#4207)

* Use passive listeners in prefetch

Without passive=true, Lighthouse complains about not using passive listeners to improve scrolling performance.

* Create cold-shoes-drum.md

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
Maik Jablonski 2022-08-11 18:04:10 +02:00 committed by GitHub
parent 54ff0a454c
commit ceb0eef944
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
"@astrojs/prefetch": patch
---
Use `passive` event listeners for performance

View file

@ -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) {