dynamic-import

Lazily load non-critical JavaScript or TypeScript modules with React.lazy and Suspense.

Updated Mar 27, 2026
One-click install
npx skills add https://github.com/quanngynx/GDGO-2026.Servexa-Warranty-AI --skill dynamic-import-quanngynx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dynamic-import
Source: https://github.com/quanngynx/GDGO-2026.Servexa-Warranty-AI/tree/main/servexa-warranty-ai/.agents/skills/dynamic-import
Command: npx skills add https://github.com/quanngynx/GDGO-2026.Servexa-Warranty-AI --skill dynamic-import-quanngynx

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Dynamic import prevents loading rarely used UI components upfront, reducing initial bundle size and improving perceived load performance.

Core Features & Use Cases

  • On-demand module loading: Lazily load a component only when it is needed (for example, when a user opens an EmojiPicker).
  • React Suspense integration: Use Suspense to delay rendering until the dynamically imported module is ready.
  • SSR-friendly alternative: Use loadable-components when React Suspense is not supported in server-side rendering.

Quick Start

Use React.lazy with Suspense to dynamically import the non-critical component and render a fallback UI while it loads.

Frequently Asked Questions about dynamic-import

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce initial bundle size with dynamic import in React?

To reduce initial bundle size with dynamic import in React, use React.lazy to lazily load non-critical JavaScript modules and wrap them in a Suspense boundary with a fallback UI for on-demand rendering.

What is lazy loading and when should I use it for web components?

Lazy loading is a technique to load components on demand rather than upfront. Use it for non-critical UI features like modals, pickers, or heavy widgets triggered by user interaction instead of initial render.

Does React Suspense work with server-side rendering for code splitting?

React Suspense does not fully support server-side rendering for code splitting. Use loadable-components as an SSR-friendly alternative to achieve dynamic import semantics and on-demand module loading in SSR scenarios.

How do I show a fallback UI while waiting for a dynamically imported module?

To show a fallback UI while waiting for a dynamically imported module, wrap your React.lazy component inside a Suspense component and provide a meaningful fallback prop that renders until the module is loaded.

What is the best way to optimize bundle performance for heavy widgets?

The best way to optimize bundle performance for heavy widgets is applying code splitting via dynamic import semantics. This prevents loading rarely used UI components upfront, reducing initial bundle size and improving load performance.