<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tim Jat</title>
    <description>The latest articles on DEV Community by Tim Jat (@timjat).</description>
    <link>https://dev.to/timjat</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3302876%2F7f62ef9a-79f3-4b0a-9899-5149012e33ba.jpeg</url>
      <title>DEV Community: Tim Jat</title>
      <link>https://dev.to/timjat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/timjat"/>
    <language>en</language>
    <item>
      <title>What is Layout, Paint, Composite? and How Do They Affect Web Performance?</title>
      <dc:creator>Tim Jat</dc:creator>
      <pubDate>Thu, 31 Jul 2025 00:19:01 +0000</pubDate>
      <link>https://dev.to/timjat/what-is-layout-paint-composite-and-how-do-they-affect-web-performance-48ml</link>
      <guid>https://dev.to/timjat/what-is-layout-paint-composite-and-how-do-they-affect-web-performance-48ml</guid>
      <description>&lt;h2&gt;
  
  
  What are Layout, Paint, and Composite?
&lt;/h2&gt;

&lt;p&gt;Layout, Paint, and Composite are crucial steps in the browser's Rendering Pipeline.&lt;/p&gt;

&lt;p&gt;When a browser renders a webpage, it starts by processing the HTML and CSS. Then it figures out which CSS styles apply to each HTML element (this builds the Render Tree). After that, the browser performs the following steps in order: Layout &amp;gt; Paint &amp;gt; Composite&lt;/p&gt;

&lt;h3&gt;
  
  
  Layout
&lt;/h3&gt;

&lt;p&gt;Calculates where each element should appear on the page and how big it should be. Involves CSS like &lt;code&gt;margin&lt;/code&gt;, &lt;code&gt;top/right/bottom/left&lt;/code&gt;, &lt;code&gt;width&lt;/code&gt;. If any of these properties change, the browser must recalculate everything, a process called Reflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  Paint
&lt;/h3&gt;

&lt;p&gt;Fills in the pixels e.g. &lt;code&gt;border&lt;/code&gt;, &lt;code&gt;background-color&lt;/code&gt;, &lt;code&gt;visibility&lt;/code&gt;. If this step runs again, it's called a Repaint.&lt;/p&gt;

&lt;h3&gt;
  
  
  Composite
&lt;/h3&gt;

&lt;p&gt;For certain CSS properties like transform and opacity, the browser promotes the element to its own layer and uses the GPU to process it. This is faster than relying solely on the CPU. Finally, all the layers are composited (combined) to produce the final result on screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx9kralrwwmi53ptlgycs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx9kralrwwmi53ptlgycs.png" alt="Layout - Paint - Composite" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Do They Affect Performance?
&lt;/h2&gt;

&lt;p&gt;CSS can change dynamically through interactions like &lt;code&gt;:hover&lt;/code&gt;, &lt;code&gt;:active&lt;/code&gt;, or via CSS animations and transitions. Each of these can trigger different parts of the rendering pipeline.&lt;/p&gt;

&lt;p&gt;These steps are sequential:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If Layout (Reflow) is triggered: the browser must perform Layout &amp;gt; Paint &amp;gt; Composite&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If Paint (Repaint) is triggered: the browser must perform Paint &amp;gt; Composite&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If only Composite is triggered: only Composite step is run (most efficient)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Triggering Reflow or Repaint is more expensive than triggering Composite-only operations, which are GPU-accelerated and lightweight.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48x814bpn9vogzxvpouq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48x814bpn9vogzxvpouq.png" alt="Sisyphus of the Render Pipeline" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo: CSS Reflow vs Composite Performance
&lt;/h2&gt;

&lt;p&gt;Check out the &lt;a href="https://pariyawit.com/css-performance-demo" rel="noopener noreferrer"&gt;CSS Reflow vs Composite Performance Demo&lt;/a&gt; I created to see this in action. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9z1c14zxgobtdf8937pd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9z1c14zxgobtdf8937pd.png" alt="CSS Reflow vs Composite Performance Demo" width="800" height="642"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A selector to control how many balls are animated&lt;/li&gt;
&lt;li&gt;Toggles to enable/disable each animation group&lt;/li&gt;
&lt;li&gt;Two groups of balls (A &amp;amp; B) moving left and right&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How do they differ?&lt;br&gt;
Group A uses &lt;code&gt;left&lt;/code&gt; (triggers Layout &amp;gt; Paint &amp;gt; Composite)&lt;/p&gt;

&lt;p&gt;Group B uses &lt;code&gt;transform: translateX()&lt;/code&gt; (triggers only Composite)&lt;/p&gt;

&lt;h3&gt;
  
  
  Paint Flashing
&lt;/h3&gt;

&lt;p&gt;Enable Paint Flashing in Chrome DevTools:&lt;/p&gt;

&lt;p&gt;You'll see Group A constantly repainting due to left triggering reflow/repaint.&lt;/p&gt;

&lt;p&gt;Group B, using transform, won't flash — because it bypasses reflow/paint entirely.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe2xt4g6rlmau4kcnw2bi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe2xt4g6rlmau4kcnw2bi.png" alt="Group A triggers Repaint" width="800" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Performance Monitor
&lt;/h3&gt;

&lt;p&gt;Set the ball count to 1,000 and toggle to show only Group A, then open Performance Monitor:&lt;/p&gt;

&lt;p&gt;Group A shows high CPU usage and spikes in Layouts and Style Recalcs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx7rwqr85zyqigd1j9kih.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx7rwqr85zyqigd1j9kih.png" alt="Group A — High CPU usage" width="800" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Switch to Group B and you'll see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lower CPU&lt;/li&gt;
&lt;li&gt;Fewer style recalcs / sec&lt;/li&gt;
&lt;li&gt;Layout/sec drops to zero&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fboyybd2b3cmhr6m8v9q5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fboyybd2b3cmhr6m8v9q5.png" alt="Group B — Lower CPU usage" width="800" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Layout, Paint, and Composite are essential to rendering a web page.&lt;br&gt;
Different CSS properties trigger different steps.&lt;br&gt;
Understanding these can give you powerful tools to diagnose and improve performance.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/Performance/Guides/How_browsers_work" rel="noopener noreferrer"&gt;Populating the page: how browsers work&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://web.dev/articles/rendering-performance" rel="noopener noreferrer"&gt;Rendering performance&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
