Code Splitting

  • This lesson introduces code splitting in React and explains how it helps reduce initial load time.

  • Code Splitting

    What is Code Splitting?

    Code splitting means breaking the app into smaller chunks instead of one large bundle.

    Only load code when needed.

    Benefits:

    • Faster initial load

    • Reduced bundle size

    • Better performance

    Dynamic Imports

    Dynamic imports load components on demand.

    Example:

import("./MyComponent");
  • Loaded only when required.