Closed Aleksion closed 5 years ago
Hello @Aleksion, in your example, all components are mounted so all components are loaded. You have to find a way to avoid mounting all components. I think you should probably ask on @reach/router
because it is very specific to this project. Using react-router
you don't have this kind of issue because the component is only mounted if the route matches.
💬 Questions and Help
Hi,
I'm trying to optimize our page speed as much as possible, and one of the things that seem to be hurting it right now is the fact that ALL of the applications scripts are preloaded - even though only a few are needed for the initial screens. It hikes up the execution time of javascript, everytime I add a new route. My question is, is there a way to do code splitting, BUT defer fetching the bundles until the user navigates to a screen?
My guess is that I'm configuring things the wrong way in my router, but I havne't managed to hit a configuration that doesn't result in all the chunks being listed as required and loaded here:
This is what my Router looks like:
And my SSR configuration is as follows:
Loadable Components project is young, but please before asking your question:
After you can submit your question and we will be happy to help you!