首页/ AI 技能 / @skilllib/skill-2014279397090471938
Skill站外收录 @skilllib/skill-2014279397090471938

bundle-dynamic-imports

通过动态导入机制实现重型组件的按需加载,将编辑器、图表、富文本等体积较大且非首屏必需的组件延迟到实际使用时再加载,从而显著减小主包体积并提升页面初始加载性能。

0.0 (0) 168 次安装 原作者 编程导航
收录于 2026-01-22
软件开发 AI 技能

Skills.MD

## Dynamic Imports for Heavy Components Use `next/dynamic` to lazy-load large components not needed on initial render. **Incorrect (Monaco bundles with main chunk ~300KB):** ```tsx import { MonacoEditor } from './monaco-editor' function CodePanel({ code }: { code: string }) { return <MonacoEditor value={code} /> } ``` **Correct (Monaco loads on demand):** ```tsx import dynamic from 'next/dynamic' const MonacoEditor = dynamic( () => import('./monaco-editor').then(m => m.MonacoEditor), { ssr: false } ) function CodePanel({ code }: { code: string }) { return <MonacoEditor value={code} /> } ```

评论 0

还没有评论,来抢沙发。