Code splitting breaks apart the various pages of your application into smaller bundles, which are then loaded on demand when visiting new pages. This can significantly reduce the size of the initial JavaScript bundle loaded by the browser, improving the time to first render. While code splitting is helpful for very large projects, it does require extra requests when visiting new pages. Generally speaking, if you’re able to use a single bundle, your app is going to feel snappier. To enable code splitting, you will need to tweak theDocumentation Index
Fetch the complete documentation index at: https://inertiajs.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
resolve callback in your createInertiaApp() configuration, and how you do this is different depending on which bundler you’re using.
Using Vite
Vite enables code splitting (or lazy-loading as they call it) by default when using theirimport.meta.glob() function, so simply omit the { eager: true } option, or set it to false, to disable eager loading.
Using Webpack
To use code splitting with Webpack, you will first need to enable dynamic imports via a Babel plugin. Let’s install it now..babelrc file in your project with the following configuration:
resolve callback in your app’s initialization code to use importinstead of require.