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

fix: don't wrongly abort preload fetch requests #124

Closed hirasso closed 8 months ago

hirasso commented 8 months ago

The problem

Currently, all preload requests after the first page:view are being exited early. The reason for this is that swup.fetchPage falls back to swup's internal visit object if we don't provide a custom visit to it. It then calls the hook fetch:request that exits early if the visit is already done.

The solution

Pass the temporary visit from performPreload along in the FetchOptions for fetchPage.

Future

I'd like to merge this as soon as possible, we can discuss possible improvements later.

Checks

github-actions[bot] commented 8 months ago

Playwright test results

passed  88 passed
skipped  4 skipped

Details

stats  92 tests across 8 suites
duration  1 minute, 25 seconds
commit  a0422a6

Skipped tests chromium → preload-plugin.spec.ts → active links → preloads links on touchstart firefox → preload-plugin.spec.ts → active links → preloads links on touchstart webkit → preload-plugin.spec.ts → active links → preloads links on touchstart ios → preload-plugin.spec.ts → active links → preloads links on hover
daun commented 8 months ago

Nice! I'd tend to answer no to both questions – the FetchOptions interface is also part of the public API of navigate() and I'd rather keep that clean. We might refactor the whole thing though because currently it's a bit messy 🤠