
Description
Dynamic Import is an agent skill that teaches on-demand code loading with the dynamic import() syntax. The example is a chat application with four components: UserInfo, ChatList, ChatInput and EmojiPicker. Only the first three are needed on the initial load. The EmojiPicker may never render if the user never clicks the emoji button, so loading it eagerly makes the initial bundle larger and the page slower to load. The fix is to import it only when it is needed. In React, the skill suggests React.lazy with Suspense for dynamic component imports, and a meaningful fallback UI while the module loads. For server-rendered applications where Suspense is not supported, it suggests loadable-components. Use the technique when certain modules are only needed based on user interaction or conditions, such as modals, pickers or heavy libraries that are not needed on the first render. Only dynamically import modules that are not critical to the initial render. The skill is part of the patternsdev skills collection on GitHub.…
Highlights
- Loads modules only when the user needs them
- React.lazy with Suspense and a fallback UI
- loadable-components for server-rendered apps
- Reduces the initial bundle size
Ratings & Reviews
No ratings yet
Be the first to rate dynamic-import.
People also visit

react-ui-patterns
Modern React UI patterns for loading states, error handling, and data fetching
dynamic-import FAQ
What does this skill make the agent do?
It guides the agent to load heavy modules, such as a picker or modal, only when the user needs them.
Which React approach does it use?
React.lazy with Suspense, with a fallback UI while the module loads.
What about server-rendered apps?
It suggests loadable-components, because React Suspense is not supported there.
When should I not use it?
For modules that are critical to the first render.
How do I install it?
Run npx skills add https://github.com/patternsdev/skills --skill dynamic-import.
What are the best dynamic-import alternatives?
Popular alternatives to dynamic-import include import-on-interaction, import-on-visibility and react-ui-patterns. See all dynamic-import alternatives













