T
TanStack2y ago
quickest-silver

Upcoming Preloading Strategies: Progress and Release Date?

Excited about the upcoming "Render" and "Viewport Visibility" preloading strategies mentioned in the docs! Any progress updates and a ballpark release date? Thanks.
No description
6 Replies
quickest-silver
quickest-silverOP2y ago
@Tanner Linsley
foreign-sapphire
foreign-sapphire2y ago
I outright forgot that there were plans to introduce other preloading strategies for over a year now.
quickest-silver
quickest-silverOP2y ago
I think it’s quite important! We need these as early as possible
foreign-sapphire
foreign-sapphire2y ago
That'll be up to Tanner, since he'd need to define exactly what these other strategies will encompass and their behaviours. Not to mention then adding them in and ironing out all the edge-cases for them. Currently, we haven't gotten a single request for other strategies since most people get by just fine with the "intent" strategy, or they other are doing something so custom that they just build a function/component that uses the router to call the preload method. Maybe drop a comment in the v2 discussion thread on github, and Tanner can decide on whether its something he wants to ship in this current version of Router or whether he'd want it to be shipped with the next.
GitHub
V2 · TanStack router · Discussion #975
Moving away from classes Classes are great for defining types and functionality in one go, but they're not very friendly to destructuring and compositional/functional APIs. The following change...
foreign-sapphire
foreign-sapphire2y ago
Regarding my (super basic) understanding of the Render and Viewport strategies (purely from their names alone), you'd be able to hack it in yourself. For Render you could create a no-op component or a wrapper around <Link />that calls router.preload as soon as its renders in the React DOM tree. Similarly for Viewport, and my extremely limited understanding of how it could work, you do something similar to the solution for the Render strategy above, except you'd call the preload method only when the component comes into view. The comes-into-view part is quite easy to solve, given that the web has had the IntersectionObserver API for a long time now.
quickest-silver
quickest-silverOP2y ago
The current approach of on-hover preloading is not quite helpful at all, if the router component size is big. We get a loading splash screen. which is quite annoying UX I think! So we need at least one of the other strategies. maybe I will go for manual as of now. But getting support from the library out of the box will be helpful!

Did you find this page helpful?