swup / preload-plugin

A swup plugin for preloading pages to speed up navigation 🚀
https://swup.js.org/plugins/preload-plugin
MIT License
14 stars 14 forks source link

Links with identical `href` will remove urls from `preloadVisibleLinks` queue even if these should actually be preloaded. #104

Closed hirasso closed 1 year ago

hirasso commented 1 year ago

Description of the issue

Imagine a sub page of a website where there is a link to let's say /, both at the very start as well as in the footer of the document. preloadVisibleLinks will never preload the first element on the page, even though it's in the viewport. The reason for that is that the the link to / in the footer is not in the viewport and thus will immediately remove the link again, just after it was added for the first link.

Workaround

Providing a data-swup-preload attribute manually.

Possible Solution

Haven't thought about a solution, yet 😄 ...but we definitely need one.

daun commented 1 year ago

Interesting. I'd have hoped the intersection observer fires only when the visibility state actually changes, not initially. Admittedly, that part is very much inspired by quicklink and seems to have the same problem with duplicate links.