Skip to content
Tutorials Center
My learning

Topics

Lesson 31 of 36 ยท Debugging Workflows

Debugging Slow Page Loads

Diagnose a slow page: read the Network waterfall, find the critical rendering path, spot render-blocking resources and late discoveries, and prioritize fixes.

"The page is slow" is not a diagnosis. A slow load has a specific shape: perhaps the server answered late, a script blocked rendering, the hero image was found too late, or a huge bundle took a long time to run. DevTools can show every one of these, and this lesson gives you a workflow that moves from symptom to cause in a fixed order.

You will use the Network panel for the waterfall, the Performance panel for what the main thread did, and Lighthouse for a second opinion.

Step 1: set up an honest test

Open an Incognito window with DevTools. In the Network panel tick Disable cache and select Fast 4G (or Slow 4G); in the Performance panel set CPU 4x slowdown. Cold-cache load on a throttled mobile profile is what your slowest users see. Optionally keep a second profile for repeat visits with the cache enabled.

Step 2: read the waterfall

Reload with the Network panel open. Each row is a request; bars show phases (queueing, DNS, connect, TLS, waiting for the first byte (TTFB), content download). Two vertical lines mark DOMContentLoaded (blue) and load (red). Right-click the column header to add Priority, Initiator and Protocol. Questions to ask, in order:

  1. How long until the HTML arrives? A large "waiting" bar on the first request means a slow server, a slow database query or a redirect chain. Fix the backend or add caching or a CDN before touching the front end.
  2. What blocks rendering? CSS in the head and synchronous scripts block the first paint. In the Performance panel they appear as long yellow/blue sections before the first paint. Add defer or async to scripts and inline critical CSS or split non-critical CSS.
  3. What is found late? Select the LCP image request and read its Initiator. If the image is requested by a script or a CSS file instead of the HTML, the browser learned of it late. Use an <img> in the HTML with fetchpriority="high", or a <link rel="preload">.
  4. Which requests are huge? Sort by Size and by Time. Look for uncompressed text (check the content-encoding header for gzip or br), unoptimized images, and megabyte JavaScript bundles.
  5. Are connections wasted? Many different origins each pay DNS, TCP and TLS cost; <link rel="preconnect"> for the important ones, and HTTP/2 or HTTP/3 to avoid per-connection queueing.
  6. What happens after the bytes arrive? In the Performance panel, long scripting blocks after download point to parse and execute cost, solved by shipping less code.

The critical path as data

The critical rendering path is the chain of resources that must complete before the first paint. Each resource can start only when the thing that references it has loaded. Given dependencies and sizes, the earliest finish time of each resource is computed by walking that graph, which is what the waterfall visualizes. The stand-in below does the arithmetic with made-up numbers so that you can try "what if I preload this?" experiments.

JS Stand-in: finish times along the critical path

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Moving the image's discovery from JavaScript to HTML saves 600 ms without making any file smaller, which is the typical result of fixing a discovery problem instead of a size problem. The waterfall shows it as a staircase turning into parallel bars.

Step 3: check the main thread

After the load, switch to Performance and record with reload. Look at:

  • Time to first paint (FCP) versus LCP: a big gap points to a late or heavy hero element.
  • Long tasks (red marks) during load and what scripts they belong to; group Bottom-Up by Third Party.
  • Network track versus main track: a main thread that is idle while requests are pending means you are network-bound; one that is busy means CPU-bound.

Step 4: prioritize

Rank problems by expected gain over effort. A good order is: server response and caching, render-blocking resources, LCP discovery and priority, image size and format, JavaScript size and execution, then fonts and third parties. The stand-in below turns that into a tiny scoring table.

JS Stand-in: rank fixes by gain per effort

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The cheap, high-gain fixes rise to the top; the big rewrite lands last despite the largest absolute gain.

Step 5: confirm and guard

Record again with the same throttling, compare LCP and TBT, and run Lighthouse. Then guard the improvement: set a performance budget (maximum JavaScript size, maximum LCP) and run Lighthouse CI in your build so regressions fail the build, instead of being discovered months later.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. The first request shows a very long green 'waiting (TTFB)' bar. What is the most likely cause?

    Waiting time is the time until the first byte arrives, mostly server work and network latency.
  2. 2. The LCP image's Initiator is a JavaScript file. What does this suggest?

    Images found by scripts start loading later than those in the HTML; prefer an img element or a preload.
  3. 3. Why throttle the CPU and network and disable cache when debugging loads?

    Slow users hit cold caches on weaker hardware; testing that profile reveals real bottlenecks.
  4. 4. What does a performance budget do?

    A budget turns performance goals into a pass/fail check in CI.

Summary

  • Test cold-cache, throttled, in Incognito.
  • Read the waterfall: TTFB, render-blocking resources, late discovery, size, connections.
  • Check the main thread to decide whether you are network-bound or CPU-bound.
  • Prioritize by gain per effort, then re-measure and add budgets.

Next: Finding Memory Leaks