Token导航 LogoToken导航TokenDH.com
开发只读github未标认证来源可访问许可证需确认审计通过

dynamic-import动态导入

Agent Skill

dynamic-import 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

6,365

周安装

260

GitHub Stars

173

下载量

2,059
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:dynamic-import(动态导入)
来源仓库:https://github.com/patternsdev/skills
仓库路径:skills/dynamic-import
安装命令:
npx skills add https://github.com/patternsdev/skills --skill dynamic-import
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/patternsdev/skills --skill dynamic-import

简介

dynamic-import 按需异步加载组件模块,减少初始 bundle 体积与首屏加载时间。

  • 适用于聊天应用、仪表盘与多视图系统的代码分割优化场景。
  • 结合 React.lazy 与 Suspense 实现平滑过渡与错误边界处理。
  • 需确认打包工具(Webpack/Vite)支持动态 import 语法解析。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

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
  • Provide meaningful fallback UI while dynamically imported modules are loading
  • Consider using loadable-components for SSR applications where React Suspense isn't supported
  • Only dynamically import modules that aren't critical to the initial render

Details

Instead of unnecessarily adding EmojiPicker to the initial bundle, we can split it up into its own bundle and reduce the size of the initial bundle!

A smaller initial bundle size means a faster initial load: the user doesn't have to stare at a blank loading screen for as long. The fallback component lets the user know that our application hasn't frozen: they simply need to wait a little while for the module to be processed and executed.

Asset                             Size         Chunks            Chunk Names
emoji-picker.bundle.js           1.48 KiB      1    [emitted]    emoji-picker
main.bundle.js                   1.33 MiB      main [emitted]    main
vendors~emoji-picker.bundle.js   171 KiB       2    [emitted]    vendors~emoji-picker

Whereas previously the initial bundle was 1.5MiB, we've been able to reduce it to 1.33 MiB by suspending the import of the EmojiPicker!

By dynamically importing the EmojiPicker component, we managed to reduce the initial bundle size from 1.5MiB to 1.33 MiB! Although the user may still have to wait a while until the EmojiPicker has been fully loaded, we have improved the user experience by making sure the application is rendered and interactive while the user waits for the component to load.

Loadable Components

Server-side rendering doesn't support React Suspense (yet). A good alternative to React Suspense is the loadable-components library, which can be used in SSR applications.

Similar to React Suspense, we can pass the lazily imported module to the loadable, which will only import the module once the EmojiPicker module is being requested! While the module is being loaded, we can render a fallback component.

Although loadable components are a great alternative to React Suspense for SSR applications, they're also useful in CSR applications in order to suspend the import of modules.

Source

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.84%
按下载量换算717

Claude

32.33%
按下载量换算666

Cursor

17.84%
按下载量换算367

Gemini CLI

9.37%
按下载量换算193

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills