-
Notifications
You must be signed in to change notification settings - Fork 436
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
Prefetching #174
Comments
+1 Would love to see this implemented as an official Turbo plugin. It would be really helpful to combine Turbo with the functionality (and configurability) of something like FlyingPages or instant.page. Even allowing the option to prefetch on mouse-click down could shave off 40+ ms of latency with minimal wasted server calls. |
If like me you don't want to add npm/another toolchain to their projects someones shared prefetch.js gist https://gist.github.com/vitobotta/8ac3c6f65633b5edb2949aeff0dec69b |
Cross posting a comment for feedback on non bundler setup: fleck/nitrous-oxide#2 (comment)
|
I'd very much like to see this built into Turbo. If anyone wants to work on this, please do start a PR. |
First, thanks for turbo! I'm working on a prefetcher for turbo https://github.com/fleck/nitrous-oxide. I'm taking advantage of the browsers built in http caching and max-age header. The issue I encountered was when a user hovers over a link and clicks before that fetch is finished resulting in a double fetch. I've fixed this by tracking inflight requests.
When a user clicks a link and there's in inflight request I start the visit (I check whether this is targeting a frame or a general visit):
https://github.com/fleck/nitrous-oxide/blob/master/src/index.ts#L73
After the promise is fulfilled I then trigger a frame or regular visit:
https://github.com/fleck/nitrous-oxide/blob/master/src/index.ts#L82
This seems to work well enough, but the code feels a little janky, just wondering if you had suggestions for a better way to handoff a url and
Promise<Response>
to programmatically trigger a turbo visit/TurboFrame visit?Thanks again for the work on Turbo, It's been really nice to work with!
The text was updated successfully, but these errors were encountered: