Back

Understanding the Browser’s Rendering Cycle: A Developer’s Guide

Syed Sibtain
Syed Sibtain
render_cycle
HTMLJavaScript

Introduction: How Does the Browser Render a Web Page

When we build web apps, we usually write HTML, CSS, and JavaScript — but browsers don’t "understand" these directly. Behind the scenes, they go through a multi-step rendering process to turn our code into pixels on the screen.

This process is called the Rendering Pipeline or Render Cycle.

Browser Rendering Cycle

render-cycle

Reflow: When the Browser Recalculates Layout

After the browser is done with constructing the render tree, it needs to figure out where each element goes on the screen, their position, size and how they are related with other elements.
This process is called Reflow, also known as the Layout phase.

What Triggers a Reflow?

So basically the reflow is triggered when:

Why Is Reflow Expensive?

Reflow does not effect just one element, it can cascade through the following:

The browser has to constantly re-calculate the layout tree and then trigger paint and compositing again. In large DOMs or animations, this becomes noticeably slow.

Repaint: When Only Visuals Change

After the layout is done, or the layout does not need to change at all, the browser still need to change the appearance of elements on the screen. This stage is called Repaint (also known as the Paint phase).

Unlike Reflow, which recalculates layout, Repaint simply redraws pixels for elements whose visual styles have changed.

What Triggers a Repaint?

Repaint is triggered when we make style changes that don’t affect layout.

Why Repaint Still Matters?

Repaint is less expensive than Reflow because it doesn’t affect layout. However:

Repainting doesn't mean the browser will update the whole screen — but it will repaint the affected area, and that takes time as well.

Compositing: The Final Assembly of Layers

After painting is done, the browser has to assemble the painted elements into layers and combine them into a single image that can be sent to our screen.

Some elements may be placed into separate layers to improve rendering performance — especially when certain properties are used, like:

These layers are independently painted and then merged (composited) in the final step.

Bonus: Pre-Paint in the Browser Rendering Cycle

Pre-Paint is the phase where the browser determines what needs to be painted, which regions are invalidated, and how layers should be updatedbefore the actual Paint phase begins.

It acts as a preparation step between Layout (Reflow) and Paint.

What Happens in the Pre-Paint Phase?

In the Pre-Paint phase, the browser:

It’s basically setup work for the Paint phase, but it’s critical for:

Thank you for reading. Sometimes performance isn’t about doing more — it’s about understanding how things work under the hood.