WICG / nav-speculation

Proposal to enable privacy-enhanced preloading
https://wicg.github.io/nav-speculation/
Other
152 stars 35 forks source link

Does the Speculation Rules API support hash routing? #314

Open Rosadojonathan opened 4 months ago

Rosadojonathan commented 4 months ago

Hello,

I've been trying to get the Speculation Rules API to work with my app. I was wondering if the API was supposed to work with hash routing?

Two of my URLs which use hash routing show the hash portion in a red font which leads me to believe it didn't work properly Screenshot 2024-05-07 at 19 49 26 and when I navigate to those pages by clicking on the link, I don't seem to benefit from the prerendering.

Is there something I'm missing?

Thanks!

tunetheweb commented 4 months ago

I presume by "hash routing" you mean an SPA type architecture?

If so, then no, that is not supported by speculation rules: https://developer.chrome.com/docs/web-platform/prerender-pages#speculation_rules_and_spas

Rosadojonathan commented 4 months ago

Yes, indeed. So I should switch from prerendering to prefetching, and it should still help the loading performance to a certain extent. Thank you!

tunetheweb commented 4 months ago

I would test that to be sure, because Speculation Rules will fetch this as a document, rather than as a your SPA may fetch this (e.g. as a JSON XHR fetch request). You may be better to see what your SPA framework offers for prefetching rather than use Speculation Rules.

domenic commented 4 months ago

I wonder what a good DevTools UI would look like here, to signal that you performed a SPA navigation and so prefetch/prerender does not apply.