Inside the Frame: What Really Happens When the Browser Renders
koolcodez.com·3w·
Discuss: Hacker News
Flag this post

tldr; go to the DEMO

Whether you are using a full framework or vanilla JavaScript, the browser follows the same principles in how it operates. Understanding these principles can make the difference between a janky, frustrating experience and a smooth, enjoyable one.

Quick corrections and facts

JavaScript runs on a single thread, and it must yield control back to the browser, so that multiple tasks can run.

The browser rendering cycle for a single frame looks like this:

  1. style calculation
  2. reflow (also called layout) – computes positions and sizes
  3. repaint (also called paint) – paints pixels into layers
  4. composite – composes layers together, often on the GPU Frame budget math: There are 1000 milliseconds in one second. Dividing by 60 fr…

Similar Posts

Loading similar posts...