Learning center

The page freezes after a click: main-thread work or a slow response?

A page that freezes after a click is either running JavaScript on the main thread or waiting for a slow response. One Performance panel recording tells you which, and which team owns the fix.

Two causes that feel the same#

Cause A: the main thread is blockedCause B: the page is waiting for a response
Can you select text, type in a field or open a menu during the wait?No, or only after a delayYes
Performance recordingA long task, marked with a red triangle, covering the waitShort tasks at the click and when the response arrives, idle time between
Network panelRequests are quick, or noneOne request whose Waiting time covers most of the wait
Where the fix goesThe click handler or rendering codeThe endpoint, its query, or the network path

A task that runs longer than 50 milliseconds is a long task. While it runs, the browser cannot process input. web.dev: long tasks

The deciding observation is whether a long task covers the frozen period.

Reproduced in Chromium#

A local page had two buttons. One filtered rows by running JavaScript for 800 milliseconds. The other fetched the filtered rows from a server that answered after 800 milliseconds. The page observed long tasks and event timing.

CPU button:
  LONGTASK 829ms
  EVENT click duration=832ms processing=827ms

Network button:
  EVENT click duration=16ms processing=1ms
  response: 1200 rows after 806ms

Both buttons left the user waiting about 800 milliseconds. For the first, the click's processing took 827 milliseconds and a long task covered it: the page could not respond to anything else. For the second, the click finished in 16 milliseconds and the page stayed responsive while it waited. Long Tasks API ยท Event Timing API

Record it with the Performance panel#

  1. Open DevTools, select Performance and start a recording.
  2. Click the control that freezes the page, and wait until the page responds again.
  3. Stop the recording.
  4. In the Main track, look at the period after your click. DevTools marks a long task with a red triangle and shades the part beyond 50 milliseconds in red. Click it to see the functions that ran. In the flame chart, the widest bars took the most time, and the Bottom-up tab ranks functions by their own time. DevTools: Performance panel

If the Main track is mostly empty during the wait, look at the Network track or the Network panel for the request that started at the click and finished when the page updated. Its timing breakdown shows whether the time went to Waiting for server response or to downloading. Network timing phases

A fast development machine can hide Cause A. Set CPU throttling in the Performance panel's capture settings to approach the user's device.

Worked example: an export button that locks the tab#

This example is fictional. Users report that Export CSV on a reports page freezes the browser for several seconds on large reports. Backend engineers report that the export endpoint answers in 300 milliseconds.

A Performance recording on a large report showed the export request finishing in 310 milliseconds, then a 4.2-second long task. Its flame chart showed most of the time in a function that built the CSV by concatenating strings row by row, and in a date formatter called once per cell.

The report said: the export request takes 310 ms. After it returns, the page builds the CSV on the main thread in one 4.2-second task, so the tab cannot respond. Most time is in buildCsv and per-cell date formatting. The backend team could stop looking, and the frontend team knew which function to change.

What to put in the report#

  • Whether the page responded to typing or selection during the freeze. Scrolling can keep working while the main thread is blocked, so it is not a reliable test.
  • The longest task in the recording and its duration, with the top functions from its flame chart.
  • The duration and timing breakdown of any request between the click and the update.
  • The device and whether you used CPU or network throttling.
  • The size of the data involved, such as row counts.

A recording can be saved from the Performance panel and attached to the report. It contains the page's URLs and may contain data from the page, so check it before sharing outside your team.

Questions#

What if both causes appear?

A slow response followed by a long task is common: the page waits, then processes a large response on the main thread. Report both durations. The user feels the sum, and each team owns one part.

The page freezes only the first time. Why?

The first run may load and compile code, fill caches or fetch fonts. Record a first-time attempt in a new tab and note it, because a second recording on a warm page can hide the problem.

Does a frozen page always mean JavaScript?

Usually. Layout and style recalculation on very large pages can also produce long tasks. The flame chart labels them, such as Layout or Recalculate style, so the recording still shows where the time went.

Return to the method for browser bug reports for the other symptoms in this collection.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading