Dev.to WebDev 🛠 Dev 👁 0 📖 1 min read

Why your React page feels slow when the API is fast

The API logs for an operations dashboard show 120 ms of server work. On the screen, the first useful row takes nearly two seconds to appear. A lot can happen in the browser before that row shows up. It might be waiting o

The API logs for an operations dashboard show 120 ms of server work. On the screen, the first useful row takes nearly two seconds to appear. A lot can happen in the browser before that row shows up. It might be waiting on requests, parsing JavaScript, or rendering data it already has.

I'd record one interaction, from clicking "Open dashboard" to seeing the first useful row. Use a production build. Run it once with a cold cache and again with a warm cache, and keep those results separate. The first run is closer to what a new user sees.

Check when each request starts

Suppose the trace shows the bundle loading and parsing before the app fetches the user. Then it fetches preferences, then the worklist. If the preferences only determine which columns to show, the worklist request can start once the app knows the session. Both requests can run at the same time.

If the worklist has already arrived, I'd open the React Profiler. The table might be rendering rows below the fold. Try pagination or row virtualization based on how people move through the list. In the same recording, check what the table re-renders when someone types one character into the filter.

Use the trace to pick the fix. Loading a chart later cuts startup JavaScript. Starting the worklist earlier removes a wait between requests. Rendering fewer rows frees up the main thread.

After the change, measure when the first useful row appears and how long a keystroke takes to update the filter. Run the same test on a typical laptop and a slower device. Keep both measurements so a faster first render doesn't hide a sluggish filter.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.