Since the advent of module bundling, we thought all our asset request got solved because the bundler hands us a single bundle that represents everything. We just shove this bundle right into our app and that’s all. No that’s not all.
If your app falls in the medium or large scale size, then you might be attempting to shoot yourself on the foot. Yes, bundling is a great strategy but what happens when this download size is huge and in thousands of kilobytes. The user will have to wait for the download to complete before parsing will even start.
You can use the following strategies to effectively manage bundles in your apps:
When you split a bundle based on the routes, you can now load only what the immediately visited page needs. Then you can load the other routes code when the routes are visited.
Instead of waiting for the user to move from home to about before loading about’s code, you can prefetch about’s code while the user is still on the index route. This is referred to as prefetching. When he/she attempts to visit the about route, the route will load much faster because the code that controls it has already been fetched.
Tools and Resources
Like this article? Follow @codebeast on Twitter