Roadmaps / JavaScript / Phase 3
Phase 3 of 4 · Study weeks 9-12
The browser, the engine and memory
This phase makes the third checkpoint possible: a page that responds quickly with thousands of items, and a server whose memory you can explain.
Topics every week
- Week 98 h
- The browser rendering pipeline
- Events and delegation
- Layout thrash and long tasks
- Interaction to Next Paint (INP)
Hand inA DevTools trace of a slow interaction with the long task split and re-measured
- Week 108 h
- Hidden classes and inline caches
- Tiered compilation and deoptimisation
--trace-deopt- Writing code the engine can predict
Hand inA deopt report with a trace before and after, or an honest null result
- Week 118 h
- Garbage collection: generations and pauses
- Leaks: closures, listeners, caches, timers
- Heap snapshots and retainer paths
WeakMap,WeakRefandusing
Hand inA leak catalogue of five leaks, each found with a snapshot comparison
- Week 128 h
- Profiling with DevTools and
node --cpu-prof - Flame graphs
- Honest benchmarks (warm-up, variance)
- Soak tests
Hand inCheckpoint 3, with predicted and measured numbers side by side
- Profiling with DevTools and
Practice projects
- Practice 1, the INP hunt (Week 9): build a 5,000-row list with a filter box and find the slow interaction. Done when: the trace shows the long task split into pieces under 50 ms, and the slowest interaction falls from your baseline to 200 ms or less under 4x throttling.
- Practice 2, the deopt hunt (Week 10): find a function that keeps deoptimising with
--trace-deopt. Done when: the trace shows stable optimised code and a benchmark confirms the change, or you report that the change gained under 5% and say why. - Practice 3, the leak catalogue (Week 11): create five leaks (a listener, a growing cache, a timer, a global map, a detached DOM node) and find each. Done when: each has a snapshot comparison naming the retainer path, and a fix with a test.
- Optional, a GC pause study: measure pause times under allocation pressure. Done when: a table shows pause length against heap size for two settings.
GitHub repos to study
Existence, last commit and README notices were checked on 22 Nov 2026 by shallow clone. Every repository below had a commit in the last six months. Archive status comes from the README, not from the GitHub setting, so look again before you rely on one.
| Repo | What to read | Week |
|---|---|---|
| GoogleChrome/web-vitals | How INP is measured in the field | 9 |
| GoogleChrome/lighthouse | The audits behind the lab numbers, and what they cannot see | 9 |
| v8/v8 | The engine's docs and test flags, for the compilation tiers | 10 |
| nodejs/node | The diagnostics documentation: heap snapshots, CPU profiles | 11 |
| mcollina/autocannon | A load generator: read how it measures latency | 12 |
Milestone checkpoint
Build the Checkpoint 3 page and soak run. Write your prediction for the interaction time and the soak RSS first. Seed the listener leak, find it from two snapshots, fix it and show the second comparison. Run the 1-hour soak at 40 fetches a second. Hand in the snapshot summaries, the throttled timings with their medians and spread, and ADR-5 (what you cache on the server and how its size is bounded).
Check yourself
Answer each question in your head first, then open it to check.
Why does adding properties in a different order slow hot code?
Objects built in different orders get different hidden classes. Code that sees many shapes cannot use the fast inline cache path.What does a heap snapshot comparison show for a leak?
Objects present in the later snapshot and not in the earlier one, with the retainer path that keeps them reachable from a GC root.Why do microbenchmarks mislead, and what do you do about it?
The engine optimises away dead code, folds constants and needs warm-up. Warm up, run many times, report spread, and use realistic data.What is a long task, and why does it hurt INP?
A task that holds the main thread for more than about 50 ms. Input waits behind it. Split the work and yield to the main thread between pieces, or move it to a worker.When is
WeakRefthe wrong tool?When you need cleanup at a known time. Garbage collection timing is not specified. Use explicit disposal (using) or aWeakMapthat attaches data to an object's lifetime.