redwoodjs / redwood

The App Framework for Startups
https://redwoodjs.com
MIT License
17.24k stars 990 forks source link

Prefetching codesplit pages #3780

Open Tobbe opened 2 years ago

Tobbe commented 2 years ago

Redwood automatically codesplits your pages for you, so they're only downloaded when a user actually tries to access them.

For now they're downloaded when a user clicks on a link (or in some other way navigates) to the page. But there's an opportunity to improve the user experience here.

next.js will automatically prefetch all links visible on the screen by default. You can also configure it to instead prefetch on hover https://nextjs.org/docs/api-reference/next/link

Nuxt also prefetches visible links https://nuxtjs.org/announcements/introducing-smart-prefetching

@peterp proposed to simply preload everything as soon as there is idle network time #980 That might be easier to implement, but wouldn't allow as much control over what is prefetched or how/when it's done.

jtoar commented 2 years ago

@Tobbe there's definitely an opportunity here; this fits in well with React's Suspense story in general (fetching data as early as possible; Relay is a great example of that).