swup / preload-plugin

A swup plugin for preloading pages to speed up navigation 🚀

Home Page:https://swup.js.org/plugins/preload-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

hirasso opened this issue · comments

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.

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.