Nearby lessons
42 of 43⚡ ReactJS – Lazy Loading
📌 What is Lazy Loading?
What is Lazy Loading in React?
Lazy loading is a design pattern used to optimize web and mobile apps. The idea is simple: load critical components first and delay the loading of non-essential components until they are actually needed.
This saves bandwidth and computing resources, making your app faster and more efficient.
📌 Why Lazy Loading?
- Improves performance by reducing initial load time
- Saves bandwidth by loading resources only when needed
- Makes large applications faster and more efficient
- Optimizes user experience on slower networks (e.g., 3G)
⚙️ How to Use Lazy Loading in React?
React provides two main features for implementing code-splitting and lazy loading:
React.lazy()– lets you render a dynamic import as a normal component.React.Suspense– displays fallback UI while a lazy component is loading.
🧮 Example – Lazy Loading Components
Example04
Loading editor…
🔍 Test Lazy Loading
To see lazy loading in action:
- Right click → Inspect → Network tab
- Set throttling to 3G
- Refresh the page and observe that components load only when required
🧠 Test Your Knowledge
4 QuestionsProgress: 0 / 4