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:
parent
54ff0a454c
commit
ceb0eef944
2 changed files with 6 additions and 1 deletions
5
.changeset/cold-shoes-drum.md
Normal file
5
.changeset/cold-shoes-drum.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@astrojs/prefetch": patch
|
||||
---
|
||||
|
||||
Use `passive` event listeners for performance
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue