code splitting
Dividing an app JavaScript into several files that load only when needed, instead of one big file up front.
In more detail
Route splitting loads each screen code when the user navigates to it; interaction splitting loads heavy features when the user asks for them. Bundlers create one chunk per split point.
Example
In React you split with dynamic import and React.lazy.Related terms
- React.lazy — The React function that defines a component whose code is loaded with a dynamic import the first time it renders.
- dynamic import — The import() expression that loads a JavaScript module at run time and returns a promise for it.
- bundle — The files a build tool produces by combining an application's code and its libraries for the browser to download.
- chunk — One piece of a larger piece of data delivered by a stream.
Taught in
- Suspense Architecture: Promises, Fallbacks, And Co-ordination — React 19 & Modern Component Architecture
- Code-Splitting with React.lazy: Dynamic Imports And Chunks — React 19 & Modern Component Architecture