Performance diagnosis
What you need to know
Performance diagnosis is the process of finding the expensive part of a user journey before choosing an optimization. Network, server and browser evidence point to different remedies.
By the end, you can: identify bottleneck from evidence; prioritize changes.
Interpret a modeled image waterfall
{ "ttfbMs": 150, "imageRequestStartMs": 1900, "imageEndMs": 2200, "lcpMs": 2250, "kind": "synthetic"}Expected behavior: Image discovery is a candidate bottleneck: the image request begins much later than the initial response. Inspect the initiator before changing priority.
How it works
Start with a trace of a representative action. If the first byte is late, inspect request routing, server work, upstream delays and cache eligibility; network distance may also matter. If the first byte is prompt but the LCP image starts late, examine discovery, priority and the resource waterfall. If the image arrives early but appears late, inspect main-thread work and render delays. A long JavaScript task can block an interaction even when the network is idle; a task longer than 50 ms is commonly called a long task. Use a browser performance recording and a React profiler to distinguish CPU work, commits and network waits. CLS can arise from changing reserved image space or late content. Use hypotheses, not a universal mapping from metric to cause. Validate the fix under the same workload and retain negative functional checks.
Find long tasks in a supported browser
if (typeof PerformanceObserver !== 'undefined' && PerformanceObserver.supportedEntryTypes?.includes('longtask')) { const observer = new PerformanceObserver(list => { for (const task of list.getEntries()) console.log(task.duration); }); observer.observe({type:'longtask',buffered:true}); // Disconnect when the local diagnostic session ends.}Expected behavior: Where available, duration observations appear locally. No observations or performance gains are claimed.
Common mistake
Adding more caching cannot directly fix expensive browser event handlers. Do not label every slow interaction a server problem or measure only the home page.
Practice and verification
For a slow catalog action, draw the request timeline and list two hypotheses with evidence that would disprove each. Compare the same journey after changing one suspected cause; keep focus and error states intact.
Scope: Proposed Next.js 16.x / React 19, App Router with Cache Components disabled unless noted. Framework and browser examples are staged, not executed. Synthetic numbers are not measured performance or actual provider rates.
Further reading: Production · Vitals