code-splitting
Installation
SKILL.md
Code Splitting Skill
Purpose
Code splitting breaks a monolithic JavaScript bundle into smaller chunks loaded on demand. Instead of shipping 2MB of JavaScript upfront — most of which the user may never need — you load only the code required for the current view and defer the rest. This directly improves Time to Interactive (TTI), Largest Contentful Paint (LCP), and Total Blocking Time (TBT).
Key Concepts
Splitting Strategies
| Strategy | Granularity | Best For |
|---|---|---|
| Route-based | Per page/route | SPAs with distinct pages |
| Component-based | Per feature/widget | Heavy components (editor, chart, map) |
| Library-based | Per vendor package | Large dependencies (moment, lodash, d3) |
| Interaction-based | On user action | Features triggered by click/hover |
| Viewport-based | On scroll into view | Below-the-fold content |