liveBook · Manning

Code splitting

As explained in React Hooks in Action: With Suspense and Concurrent Mode

Code splitting is a technique that divides an application's code into separately loadable bundles.

Code splitting divides an application into separately loadable bundles instead of sending all code to the browser initially. Less-used routes or bulky components load when users need them, reducing the initial bundle. section 11.0

React combines dynamic import with lazy to load components on demand and Suspense to render fallback UI while they are unavailable. This keeps rendering declarative rather than manually updating the DOM. section 11.2

Split an application by route

A bookings app can lazy-load its Bookings, Bookables, and Users pages. Visiting Users loads that page and its dependencies, while a PageSpinner appears; unused page code remains unloaded. Nested Bookables routes can split their view, edit, and new-form components similarly. section 11.2.4

How React Hooks in Action: With Suspense and Concurrent Mode covers it

How deep it goes
Explains dynamic imports, lazy components, Suspense fallbacks, and route splitting; defers detailed error fallback handling.
Examples
Uses a bookings app with split page routes and nested Bookables view, edit, and new-form components.
What it assumes
Assumes React components, imports, rendering, and routing while contrasting dynamic loading with familiar static imports.
What you can do after
Apply it via React.lazy, dynamic import, Suspense, and route boundaries to load UI progressively with fallback content.
How it connects
Connects dynamic import, React.lazy, Suspense, fallback UI, routing, bundlers, and error boundaries.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of React Hooks in Action: With Suspense and Concurrent Mode. The section links point to the parts of the book it draws on.