INVESTIGATING

Browser performance debugging

Finding real browser and React bottlenecks before choosing an optimization.


Before reaching for useMemo, virtualization, caching, or another "faster" pattern, I want to know what is actually slow.

It is easy to see a slow React page and assume React is the problem. Sometimes it is. But time can also go into JavaScript outside React, layout, paint, network requests, or third-party code. Optimizing before checking this often means fixing something that was never the bottleneck.

Find the bottleneck first

The Chrome DevTools Performance panel is usually my starting point. I want to record one slow interaction and look at what the browser was doing during that time.

The main thread flame chart helps distinguish scripting, layout, and paint work. Long tasks are also easy to spot there. If the trace shows most time inside JavaScript and React updates, then the React DevTools Profiler becomes useful. It shows which parts of the React tree rendered and how expensive those renders were.

The important part is not to treat every re-render as a bug. Cheap re-renders are often fine. I care about work that has a visible cost for the user.

Chrome Performance documentation and React Profiler documentation are good references when the trace is not clear.

Where React Doctor fits

React Doctor is useful before and around this profiling work. It scans React code and reports problems in areas such as performance, bugs, security, accessibility, and maintainability.

For existing work, a changed-scope scan looks especially useful because it can focus on findings introduced by current changes instead of reporting everything in the project. Diagnostics include a file, line, rule, and suggested fix. Individual rules can also be explained when a finding is not obvious.

I see React Doctor as another signal, not proof of a performance bottleneck. Static analysis can tell me that the code contains a risky or inefficient pattern. The React Profiler can show that React spent noticeable time there. Chrome Performance can show whether this work was part of a slow user interaction.

That difference matters. A React Doctor finding may be worth fixing, but I still do not want to call it a performance optimization until the measurement confirms it.

What I want to keep

My preferred flow is simple: reproduce the slow interaction, profile it in Chrome, and go deeper into React only when the trace points there. React Doctor can help find suspicious code around that area or catch problems while reviewing changes.

After changing something, profile the same interaction again. If the measurement does not improve, the optimization probably did not solve the problem I was looking for.

The main rule stays the same: find the bottleneck first, then choose a tool or optimization.

References and copyright