Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does the Speculation Rules API support hash routing? #314

Open
Rosadojonathan opened this issue May 7, 2024 · 4 comments
Open

Does the Speculation Rules API support hash routing? #314

Rosadojonathan opened this issue May 7, 2024 · 4 comments

Comments

@Rosadojonathan
Copy link

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Collaborator

domenic commented May 8, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants