Code splitting divides a site’s JavaScript into chunks, such as shared code and separate page chunks. Visitors can download less code initially and fetch smaller chunks as they navigate. section 13.3 section 13.3.1
For a site with ten pages, the main options have different tradeoffs:
- One bundle keeps navigation fast, but makes visitors download all the site’s JavaScript before a page can render. section 13.3.1
- A bundle per page reduces the initial download, but navigating can require downloading dependencies already included with the first page. section 13.3.1
- A shared chunk plus page-specific chunks can limit both the initial download and later downloads. Multiple ESM chunks can add round trips; modulepreload links can start downloading needed chunks earlier. section 13.3.1
Splitting can also help browser caching: changes limited to one page’s chunk need not make visitors re-download shared code or affect other pages. Modern bundlers split code automatically using heuristics; better results may require experimenting with manual splitting and combining it with prefetching. Bundler-specific configuration is outside this treatment. section 13.3.1 section 13.3



