awesome-everything RU
↑ Back to the climb

Frontend Architecture

Code splitting: fix the waterfall

Crux Hands-on project — diagnose an over-split SPA's request waterfall on throttled 4G, re-architect the chunk graph, and prove the LCP/CLS win with before/after field-condition numbers.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 240 min

Reading about over-splitting is not the same as pulling a page out of a waterfall. Take a real app, drive it into the failure mode on throttled 4G, then re-architect the chunk graph with the unit’s decision tree — measuring at every step instead of trusting the analyzer.

Goal

Turn the unit’s mental model into a reproducible engineering loop: profile the chunk graph under field conditions, find the waterfall and the over-splits, re-split per route, defer only heavy off-first-paint components, add the right resource hints, stabilise the vendor chunk, and verify the Core Web Vitals win with before/after numbers.

Project
0 of 7
Objective

Take a multi-route SPA (your own, or build a small one) that is either over-split into a request waterfall or under-split into one giant bundle, and re-architect its chunk graph so LCP on throttled 4G drops under 2.5s and CLS under 0.1 — proving each change with measurements, not the bundle analyzer.

Requirements
Acceptance criteria
  • A before/after table measured under identical throttled-4G conditions: LCP, CLS, INP, initial-route JS bytes, and the number of sequential chunk requests on the critical path.
  • The network waterfall after the change shows the critical chunks fetched in parallel with the document (via preload) rather than discovered sequentially, with the waterfall depth visibly reduced.
  • LCP is under 2.5s and CLS under 0.1 on throttled 4G, and no above-the-fold component flashes a Suspense fallback.
  • A diff of two builds proving the vendor chunk's content-hashed URL is unchanged after a trivial app-code edit, plus a one-paragraph write-up naming which lever fixed each problem and why.
Senior stretch
  • Add a route-prefetch-on-hover layer for the whole nav and measure the click-to-interactive improvement on the prefetched routes versus cold ones.
  • Compress-test the chunking: split one shared asset two ways (few larger vs many tiny chunks) and compare total transferred (compressed) bytes to quantify the compression penalty of over-splitting.
  • Add a CI Lighthouse-CI gate that runs on throttled 4G and fails the build if LCP, CLS, or initial-route JS regresses past the budget.
  • Repeat the experiment under HTTP/1.1 versus HTTP/2 and document how the waterfall's cost changes, confirming multiplexing helps parallel requests but not the sequential discovery chain.
Recap

This is the loop you will run on every real splitting decision: measure under field conditions first (throttled 4G, not the analyzer), classify every chunk as route / heavy-deferred / over-split, re-split per route by default, defer only heavy off-first-paint widgets, add preload for critical and prefetch for likely-next, and stabilise the vendor chunk so deploys do not bust the cache. Proving the LCP and CLS win with before/after numbers on a toy app makes the production version muscle memory — the chunk graph is a budget you design, not a number to minimize.

Continue the climb ↑Build pipelines: how source becomes the bytes the browser caches
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources2
expand
  1. 01
  2. 02

Trademarks belong to their respective owners. Editorial reference only.