Skip to main content
D
React
React Code Splitting

React Code Splitting

Code splitting breaks large React apps into smaller, faster chunks.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

When developers build a massive application, downloading the entire website at once makes it load very slowly. Code splitting tells React to only download the code for the specific page the user is currently viewing, speeding up load times significantly.

Syntax

Syntax
1/* this delays loading a component */
2import { lazy, Suspense } from 'react';
3const HeavyChart = lazy(() => import('./HeavyChart'));
4
5<Suspense fallback={<div>Loading chart...</div>}>
6  <HeavyChart />
7</Suspense>

Key Points

  • It uses the `lazy()` function to delay loading.
  • The `Suspense` component wraps the delayed code.
  • The `fallback` prop shows a loading spinner while it downloads.
  • It drastically improves website performance.

Up Next

Continue your journey with the next topic.

Go to React Error Boundaries