What happened

Browser rendering involves a complex pipeline of steps to update the visual display. First, a ‘paint’ operation computes each element’s position and size (also called reflow), followed by generating paint commands describing what to draw in which colors.

If nothing changed, these steps are skipped entirely, so they don’t necessarily run every frame. Only the final compositing step, which takes the produced output and assembles it on screen, is handed off to the compositor thread. This process demands precision and speed. Frames have to be drawn at the display’s refresh rate – typically 60Hz or 120Hz – meaning around 60 or 120 frames per second respectively, or about 16.6 or 8.3 milliseconds per frame. However, not all of this time is available; most of it is consumed by the browser’s own overhead processing.

Why it matters

The constraints of this pipeline are critical to web application responsiveness. JavaScript was designed around a single-threaded event loop model.

The main thread processes one task at a time, and while that task is running, nothing else can happen. If one JavaScript function runs for 200 milliseconds, then for those 200 milliseconds the browser can’t repaint the screen or receive a click from the user. This highlights how crucial efficient JavaScript code becomes to avoid blocking the rendering process.

But, but, but…

The fixed frame budget forces developers to carefully manage the execution time of JavaScript operations and CSS animations.

Anything that takes longer than this can ‘freeze’ the browser – particularly noticeable when pressing a button that triggers a long-running JavaScript animation. This demonstrates how a single misjudged action could halt the entire display, highlighting the significant impact of exceeding the frame budget.

“The problem is that the two kinds of work above stand in a single line on the same thread.”
— Dr Non

The counter-take

The prevailing narrative around web performance frequently oversimplifies the complexities of browser rendering. Ignoring this fixed budget leads to developers optimizing for factors that aren’t truly bottlenecks – a dangerous game of guessing at the source of slowdowns.

The AI angle

AI-powered UI frameworks can help optimize rendering operations by minimizing reflows and repaints, leading to improved performance and responsiveness.