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:

  1. Right click → Inspect → Network tab
  2. Set throttling to 3G
  3. Refresh the page and observe that components load only when required

🧠 Test Your Knowledge

4 Questions
Progress: 0 / 4