Course contentsShow
← React
Lesson 2214 of 2,39649. Performance: Identifying ProblemsFree lesson

Recording on Page Load vs On Interaction

The difference between profiling initial mount performance and profiling user interactions like clicks or typing.

Recording on Page Load vs On Interaction

What you'll learn: How to profile different phases of your app's lifecycle — initial mount versus user-triggered updates — to diagnose the right performance problems.

The Two Critical Performance Scenarios

When using the React DevTools Profiler, when you start and stop recording dramatically changes what you're measuring:

Recording on Page Load

Start recording before the app mounts, then immediately load or refresh the page. This captures:

  • Initial component tree construction
  • First render of all components
  • useEffect callbacks firing after mount
  • Data fetching initiated on load

This reveals problems like:

  • Too many components rendering on initial mount
  • Heavy computation in component bodies during first render
  • Expensive useMemo/useCallback initialization

Recording on Interaction

Start recording after the app has loaded, then perform a specific user action (click a button, type in an input, navigate to a route). This captures:

  • Only components that re-render due to that action
  • State updates triggered by the interaction
  • Effects running in response to the change

This reveals problems like:

  • Unnecessary re-renders from unrelated state changes
  • Components that should be memoized
  • Expensive computations happening on every keystroke

Why the Distinction Matters

Analogy: It's like debugging a car's performance. Testing acceleration from a standstill (page load) reveals different issues than testing responsiveness while already driving (interactions). You need different tools for each scenario.

If users complain about "slow typing," record typing interactions — not page load. If they complain about "long initial load time," profile the mount phase.

Key Takeaway: Always profile the specific scenario where users experience slowness — page load and user interactions have completely different performance profiles and require different optimization strategies.