0Pricing
CSS Academy · Lesson

Layout Paint and Composite: The Rendering Pipeline

Understand the browser's layout, paint, and composite pipeline to predict style change costs.

Layout Paint and Composite: The Rendering Pipeline is a free CSS Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the CSS Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

The Three Rendering Stages

After the render tree is built, the browser runs three stages: Layout (calculating element sizes and positions), Paint (filling pixels with colors/text/images), and Composite (combining painted layers and displaying them on screen).

Layout (Reflow)

Layout calculates geometry — width, height, x/y position — for every element. Changing properties that affect geometry (width, margin, padding, font-size, position) triggers layout for the element and potentially its entire subtree — the most expensive stage.

Paint

Paint fills pixels for each layer: backgrounds, borders, text, shadows. Changing color, background-color, visibility, or border-radius triggers repaint without relayout — cheaper than layout but still costly if a large area repaints.

Composite

The compositor combines layers using the GPU. CSS properties that only affect compositing — transform and opacity — can be animated without triggering layout or paint. The GPU handles them at 60fps with minimal CPU involvement.

CSS Triggers Reference

csstriggers.com (now browser-side docs) documents which CSS properties trigger layout, paint, and/or composite for each browser engine. Use it to audit animation properties. Prefer transform/opacity for animated properties.

Layout Thrashing

Layout thrashing occurs when JavaScript alternates between reading layout properties (offsetWidth) and writing style properties in a loop. Each write invalidates layout; each read forces a synchronous reflow. Batch all reads before all writes to avoid thrashing.

// BAD: read-write-read-write loop
elements.forEach(el => { const w = el.offsetWidth; el.style.width = w + 10 + "px"; });
// GOOD: batch reads then writes

Compositor-Only Properties

Only transform and opacity are handled entirely by the compositor when the element is on its own layer. Animating any other property — even left/top — triggers layout or paint on the main thread and can cause jank.

GPU Layer Creation

Browsers promote elements to their own GPU layer when they have will-change: transform, a CSS animation on transform/opacity, a fixed position with compositing neighbors, or a 3D transform. Each layer uses GPU memory — too many layers cause memory pressure.

Avoiding Paint Storms

A paint storm occurs when a large portion of the page repaints every frame. Profile in Chrome DevTools → Rendering → Paint flashing to identify repainting areas. Isolate frequently animated elements on their own layers to contain repaint area.

DevTools Performance Panel

Record a performance profile in Chrome DevTools. The flame chart shows Layout, Update Layer Tree, Paint, and Composite events. Long layout or paint bars indicate bottlenecks. Aim for frame times under 16ms to maintain 60fps.

Practical Animation Guidelines

Animate with transform and opacity whenever possible. Use clip-path instead of width/height for reveal animations — clip-path is compositor-friendly in modern browsers. Avoid animating box-shadow; use opacity + a pseudo-element with pre-rendered shadow instead.

Knowledge Check

Which two CSS properties can be animated without triggering layout or paint?

Summary

The rendering pipeline — Layout, Paint, Composite — determines animation performance. Layout is most expensive, paint is moderate, and composite-only properties (transform, opacity) are GPU-handled. Understanding triggers enables building smooth 60fps animations without layout thrashing or paint storms.

Frequently asked questions

Is the “Layout Paint and Composite: The Rendering Pipeline” lesson free?

Yes — the full text of “Layout Paint and Composite: The Rendering Pipeline” is free to read here on the web, and the CSS Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the CSS Academy course, upgrade to CoddyKit PRO.

What will I learn in “Layout Paint and Composite: The Rendering Pipeline”?

Understand the browser's layout, paint, and composite pipeline to predict style change costs. You practise CSS Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start CSS Academy?

No prior experience is required. CSS Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Layout Paint and Composite: The Rendering Pipeline” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this CSS Academy lesson?

Yes. Every CSS Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Critical CSS and Render Blocking
  2. Layout Paint and Composite: The Rendering Pipeline
  3. will-change and Layer Promotion
  4. CSS Coverage and Unused Styles
← Back to CSS Academy