sveltejs / sapper

The next small thing in web development, powered by Svelte
https://sapper.svelte.dev
MIT License
7.02k stars 437 forks source link

Prioritise prefetching #59

Open Rich-Harris opened 6 years ago

Rich-Harris commented 6 years ago

At present, Sapper prefetches all code-split chunks in no particular order. It could do better. In increasing order of difficulty:

Also, in some cases it'd make sense not to prefetch at all.

Rich-Harris commented 6 years ago

We could also prefetch but not parse JS until needed.

lukeed commented 6 years ago

What I'm doing with my project is downloading only the files needed for the current page. Then on link hover, I prefetch that href's assets.

Rich-Harris commented 6 years ago

As of 0.8, preloading secondary routes no longer happens automatically, but via a preloadRoutes function. So I'll close this — explicit user control is always the best way

Rich-Harris commented 6 years ago

Relevant article, if we were ever to decide to do predictive prefetching based on user behaviour http://blog.mgechev.com/2018/03/18/machine-learning-data-driven-bundling-webpack-javascript-markov-chain-angular-react/

Rich-Harris commented 6 years ago

@ansarizafar found this video, which appears to be covering the same stuff as the blog post — leaving it here as a reference https://www.youtube.com/watch?v=L5tPWCB7jX0&feature=youtu.be