Preload Lazy Routes

Published on August 13, 2019

← Back to tips

If you are using lazy-loading (which you should), consider using a custom preloading strategy based on your use-case. This could save your users a lot of bandwidth as the default is to preload all modules.

You can setup a custom strategy that uses quicklink, a library by Chrome Labs that uses an algorithm to identify which links should be prefetched.

Reference: https://blog.mgechev.com/2018/12/24/quicklink-angular-prefetching-preloading-strategy/

If not, how about a one that lazy-loads modules based on your network state? This can reduce the cost of loading on slower network connections.

Reference: https://dev.to/lacolaco/network-aware-preloading-strategy-for-angular-lazy-loading-4hae

🎉 Interested in Frontend or Indie-hacking?

I talk about the latest in frontend, along with my experience in building various (Indie) side-projects