Dynamic Import
Teaches dynamic import() for on-demand code loading. Use when you need to reduce initial bundle size by lazily loading modules that aren't required at startup.
Install
npx skills add PatternsDev/skills --skill dynamic-importgit clone --depth 1 https://github.com/PatternsDev/skills.git /tmp/skills
mkdir -p ~/.claude/skills
cp -r /tmp/skills/javascript/dynamic-import ~/.claude/skills/dynamic-importPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Dynamic Import In a chat application, we have four key components: `UserInfo`, `ChatList`, `ChatInput` and `EmojiPicker`. However, only _three_ of these components are used instantly on the initial page load: `UserInfo`, `ChatList` and `ChatInput`. The `EmojiPicker` isn't directly visible, and may not even be rendered at all if the user won't even click on the `Emoji` in order to toggle the `EmojiPicker`. This would mean that we unnecessarily added the `EmojiPicker` module to our initial bundle, which potentially increased the loading time! In order to solve this, we can _dynamically import_ the `EmojiPicker` component. Instead of statically importing it, we'll only import it when we want to show the `EmojiPicker`. An easy way to dynamically import components in React is by using **React Suspense**. The `React.Suspense` component receives the component that should be dynamically loaded, which makes it possible for the `App` component to render its contents faster by suspending the import of the `EmojiPicker` module! ## When to Use - Use this when certain modules are only needed based on user interaction or conditions - This is helpful when you want to reduce the initial bundle size for faster page loads - Use this when components like modals, pickers, or heavy libraries aren't needed on initial render ## Instructions - Use `React.lazy` with `Suspense` for dynamic component imports in React
Details
- Skill name
dynamic-import- Repository
- PatternsDev/skills
- Path
javascript/dynamic-import/SKILL.md- Repo updated
- 15 April 2026
FAQ
What does the Dynamic Import skill do?
Teaches dynamic import() for on-demand code loading. Use when you need to reduce initial bundle size by lazily loading modules that aren't required at startup.
How do I install the Dynamic Import skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add PatternsDev/skills --skill dynamic-import. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Dynamic Import popular?
It lives in PatternsDev/skills, which has 259 GitHub stars and 28 forks.
Related skills
AI UI Patterns
259PatternsDev/skills
Teaches design patterns for building AI-powered React interfaces. Use when creating chatbots, intelligent assistants, streaming UIs, or any AI-driven user experience in React.
Async Components
259PatternsDev/skills
Teaches async component loading in Vue for performance optimization. Use when you have heavy components that aren't needed on initial render and can be loaded on demand.
Bundle Splitting
259PatternsDev/skills
Teaches bundle splitting techniques for web performance. Use when your application has a large JavaScript bundle that affects load times or when you need to reduce FCP/LCP.
Factory Pattern
259PatternsDev/skills
Teaches the factory pattern for flexible object creation. Use when you need to create objects dynamically without using the new keyword or when object creation logic should be centralized.
Compression
259PatternsDev/skills
Teaches JavaScript compression techniques including Gzip and Brotli. Use when optimizing network transfer times or configuring server-side compression for production builds.
Flyweight Pattern
259PatternsDev/skills
Teaches the flyweight pattern for memory optimization. Use when your application creates large numbers of similar objects and memory consumption is a concern.
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.