Measure Before Optimizing
Performance engineering starts with one question:
What is actually slow for the user?
React can feel slow because of JavaScript, React render work, Effects, network waterfalls, bundles, hydration, layout/paint, third-party scripts, server work, excessive updates, or poor scheduling. memo, useMemo, and useCallback address only part of that space.
Interaction performance is a pipelineβ
A slowdown can happen at any stage. A React-specific optimization cannot fix a late network request, a huge third-party script, or a browser layout bottleneck.
Define the symptom preciselyβ
βApp is slowβ is not actionable.
βTyping in the search box takes 150 ms before the character appears when 10,000 rows are visibleβ gives you an interaction, dataset, and measurable outcome.
Reproduce before changing codeβ
Without controlled conditions, optimization becomes guesswork.
Measure in the right environmentβ
Development React intentionally performs extra diagnostics. Strict Mode can repeat some work in development.
Do not treat development timing as production truth.
Browser Performance panel vs React profilingβ
React 19.2 Performance Tracks can place React scheduling and component work directly on supported browser performance timelines.
Find the dominant costβ
Suppose a click trace shows:
Reducing React render from 40 ms to 30 ms helps, but layout remains the dominant bottleneck.
Render count is not the performance metricβ
Rendering is normal. Investigate work that is expensive, frequent, or disruptive enough to affect the user.
Frequency and cost are separate dimensionsβ
For too-frequent updates, consider narrower subscriptions, refs for non-render values, fewer state updates, or architecture changes. For expensive individual renders, consider algorithms, virtualization, server work, component boundaries, or targeted memoization.
Find what triggered the updateβ
A component can render because its own state changed, an ancestor rendered, Context changed, an external-store snapshot changed, Suspense retried, a Transition progressed, or framework navigation updated the tree.
Do not assume props are the cause.
Cascading updatesβ
If the value could have been derived during render, the Effect created unnecessary work.
Network waterfallsβ
Server Components, framework data APIs, preloading, and Suspense-aware data systems can help coordinate this. useMemo cannot fix a waterfall.
Bundle and hydration costβ
Measure initial JavaScript, route chunks, duplicated dependencies, editor/chart libraries, third-party scripts, and broad 'use client' boundaries.
Server-rendered HTML arriving early does not mean hydration is cheap. Hydration still loads client code, evaluates components, attaches behavior, and can run expensive calculations.
Scheduling and reducing work are differentβ
A Transition can keep urgent input responsive, but it does not make a 200 ms calculation cost 20 ms.
Practical optimization workflowβ
Example baseline:
filterRows(): 70 ms
Row tree render: 55 ms
browser layout: 15 ms
Possible fixes should target the dominant cause: data indexing, server filtering, virtualization, deferred rendering, or memoizing a verified expensive transformation.
Performance budgetsβ
Budgets should describe user-facing outcomes: search input responsiveness, route-to-useful-content timing, modal opening without input freeze, or smooth list scrolling under realistic data.
The exact target depends on the product, device, and network population.
Common mistakesβ
- Adding memoization everywhere before measuring.
- Benchmarking only development mode.
- Optimizing raw render count instead of user-visible latency.
- Ignoring browser layout/paint.
- Ignoring network or server architecture.
- Comparing different scenarios before and after.
Production rule of thumbβ
Interview questionsβ
Why start with profiling?β
Because slow UX can come from React rendering, JavaScript, network, browser layout/paint, hydration, Effects, server work, or third-party code. Profiling locates the dominant cause.
Is reducing render count always an optimization?β
No. Cheap renders can be harmless, while one expensive render can block the user. Measure time and impact.
Reducing work vs scheduling work?β
Reducing work lowers total computation. Scheduling APIs change when work runs and whether it is interruptible.
Common React source of cascading updates?β
Using Effects to derive state that could have been calculated during render, creating render β commit β Effect β update β second render.