How To Fix Forced Reflows And Layout Thrashing
April 10, 2025

Forced reflows on a website happen when running JavaScript code depends on style and layout calculations. For example, if website code is reading the width of a page element that can cause a forced reflow.
Ideally, JavaScript code does not depend on layout recalculations that happen while the code is running. Instead, the browser performs layout calculations when it needs to display content to the user.
Source: How To Fix Forced Reflows And Layout Thrashing | DebugBear
Especially before we got sophisticated layout aspects of CSS like grid and flex, it wasn’t uncommon for developers to do a lot of layout with JavaScript manipulating the DOM directly.
And like any habit that’s formed over time, we tend to keep doing it even when better ways come along.
So if you need other reasons to move away from using JavaScript to layout part or all of a web page, here it is.