Skip to main content

Browser Rendering Pipeline

The browser rendering pipeline is the process through which browsers convert HTML, CSS, and JavaScript code into what you see on the screen. Understanding the pipeline helps you optimize your web applications for better performance.

The main steps in the browser rendering pipeline are:

  1. Parsing HTML and building the DOM tree
  2. Parsing CSS and constructing the CSSOM tree
  3. Combining the DOM and CSSOM trees to create the render tree
  4. Calculating the layout of the render tree
  5. Painting the pixels on the screen
  6. Compositing layers if needed


The layout step calculates the position and size of each element on the page. If you change an element's size or position, the browser may need to recompute the layout, causing a performance hit. Minimize layout changes and avoid triggering layout recalculations whenever possible.

// Minimize layout changes
const box = document.getElementById('box'); = '100px'; = '100px';


During the paint step, the browser fills in the pixels for each visible element. Changes to an element's color, background, or other visual properties may trigger a repaint. Minimize paint changes to improve performance.

// Minimize paint changes
const text = document.getElementById('text'); = 'blue';


The compositing step is where the browser puts together different layers of the page. Some CSS properties, like opacity and transform, can be changed without triggering a layout or paint, resulting in faster performance.

// Use composite-friendly CSS properties
const image = document.getElementById('image'); = 0.5; = 'scale(1.2)';

Request Animation Frame

requestAnimationFrame is a browser API that helps you create smooth animations by scheduling your code to run before the next repaint. Use requestAnimationFrame instead of setTimeout or setInterval for animations.

function animate(element) { = `translateX(${Math.random() * 100}px)`;
requestAnimationFrame(() => animate(element));

const movingElement = document.getElementById('moving-element');

By understanding the browser rendering pipeline, you can optimize your web applications for better performance and a smoother user experience.