Skip to content
Nazmul Nikhil
Menu

Forced Reflow in PageSpeed Insights: What It Is and How to Fix It

Forced reflow happens when JavaScript makes the browser recalculate layout mid-task. Here's how to spot the code causing it and batch reads and writes.

Nazmul Nikhil

By

Head of SEO & Assistant Manager, Digital Marketing at Notionhive

Published 1 min read
Forced Reflow in PageSpeed Insights: What It Is and How to Fix It
Photo: Julia Taubitz on Unsplash

In short

Forced reflow happens when JavaScript changes the page and then immediately reads a size or position (for example offsetHeight or getBoundingClientRect()), so the browser must recalculate layout on the spot. Repeated in a loop, this is called layout thrashing and makes long tasks. The insight lists the functions responsible. The fix is to read all measurements first, then make all changes.

This is a developer-level insight. Site owners mostly need to know which script to report.

Example

// Slow: write, read, write, read...
items.forEach(el => {
el.style.width = box.offsetWidth + "px";
});

// Better: read once, then write
const w = box.offsetWidth;
items.forEach(el => { el.style.width = w + "px"; });

What to do

  1. Note the script named in the insight (often a theme, slider or chat widget).

  2. If it's third-party, update it or replace it; you can't fix their code.

  3. In your own code, batch reads before writes, and use requestAnimationFrame for visual updates.

WordPress, Shopify, Webflow and Wix: most cases come from plugins, apps or widgets. Disable them one at a time to confirm, then look for a lighter alternative.

This guide isn't affiliated with or endorsed by Google.

Sources and references

TAGSPageSpeed InsightsForced reflowLayout thrashingForced synchronous layout
Nazmul Nikhil

About the author

Nazmul Nikhil

Head of SEO & Assistant Manager, Digital Marketing at Notionhive

SEO and AI search consultant in Dhaka, Bangladesh, helping small and mid-size businesses in the USA, UK, Australia and Canada.

Need help with this?

Get it fixed with Core Web Vitals

I find the issues that cost you traffic and fix them, starting with the pages that matter most.

Keep reading

Related articles

All Page Speed & Core Web Vitals posts →

Get the next guide in your inbox

One email when a new SEO or AI search guide goes live.

Ready to grow?

Get a free audit of your website, or book a 30-minute call to talk through your goals.

Nazmul Hasan

Talk to Nazmul directly

Reply within 24h

WhatsApp +880 1682835118
nazmulnikhil@gmail.com