I am using create-react-app. I want to react-router base code-splitting but I want to get the first chunk which user open in browser and then get other chunks asynchronously in the background
Routes
const HomeModule = React.lazy(() => import('./modules/ft_home_module/src/main'));
const AuthModule = React.lazy(() => import('./modules/ft_auth_module/src/main'));
const ProfileModule = React.lazy(() => import('./modules/ft_profile_module/src/main'));
const MerchantModule = React.lazy(() => import('./modules/ft_merchant_module/src/main'));
<Route path="/home" component={HomeModule} />
<Route path="/auth" component={AuthModule} />
<Route path="/profile" component={ProfileModule} />
<Route path="/merchant" component={MerchantModule} />
suppose, if user open /home in the browser then home chunk will be loaded first after loading first chunk call other chunks asynchronously in the background
Required Output
- Open
/home
in browser - Get home chunk first
- then other three chunks asynchronously in the background
actually I am testing performance through lighthouse chrome extension. router base code-splitting gives me the good performance of the first page but when I open second page it takes time but it should not take time. I think it is possible if we get other chunks async in the background after loading first chunk