Load Rara's shop page over the road to the gudang: requests that wait on each other vs ones that leave together, each with its phases (DNS, TCP, TLS, TTFB…
Why it matters
A slow page is often not slow because its replies are big, but because its requests queue: one await holds the next request, the data is asked for only once the JavaScript runs, and the first request pays the handshake. The waterfall shows what runs in a row, what runs together, and which phase is longest; each has its own fix.
The key idea
Load time is set by the longest chain
Common mistakes
Thinking a smaller reply is always faster With small API replies the time goes on the trips: every request pays one RTT plus the server’s think time, and requests in a queue pay it again and again. Cut the trips in a row first; size matters only when the download phase is the longest.
Wondering why the first request is always slower The first request to an origin pays DNS, TCP and TLS (here three trips) before it leaves itself. The next ones reuse the same connection (keep-alive, HTTP/2) and go at once. With Connection: close, every request pays again.
Blaming a big TTFB on the network TTFB is one RTT plus the server’s think time. If the RTT is small but TTFB is big, the server is slow (a query, a render). Send Server-Timing from the server: DevTools and performance.getEntriesByType('resource') show it on that request. A CDN does not speed up a server that thinks for long.
Awaiting one by one requests that need nothing from each other Every await holds the next line, so the second request is made only after the first is home: a waterfall. Start the free ones first (const p = ambil(…)) and await later, or use Promise.all. A request that really needs another result (profil.id) must still wait: Promise.all over all three reads profil before it exists and throws a ReferenceError.
Try it in this playground
Load with await one by one Promo waits for profil to come home, though it needs nothing from it.
Start /api/promo first, await it later Two bikes leave together; the page is ready sooner.
Try Promise.all over all three ReferenceError: profil.id is read before profil exists.
Add a preload with crossorigin /api/profil leaves with app.js, and fetch() takes its reply.