question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IsHidden() causes a forced reflow

See original GitHub issue
Screenshot 2020-08-10 at 20 14 13

There’s probably something about the getComputedStyle that forces the browser to reflow, creating a performance bottleneck. https://gist.github.com/paulirish/5d52fb081b3570c81e3a#calling-getcomputedstyle

I wonder if there could be an alternative?

https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing?utm_source=devtools#avoid-forced-synchronous-layouts

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
stefcameroncommented, Apr 17, 2021

The next publish of this library will update tabbable to 5.2.0, which will give focus-trap the ability to pass the new displayCheck option down to tabbable, which could help mitigate this issue. However, this could open a can of worms for focus-trap as I noted in #362. Comments welcome.

1reaction
pythecommented, Oct 15, 2020

I see this in Chrome 86 on MacOS 10.15.7, and in Edge 84 on Windows 10 (in a VM).

I’m experiencing the same issue and interested in investigating an optimization here. In my case, an extremely large document exacerbates the problem: Each forced layout takes 600+ms. Removing the need for this recalculation would halve the execution time of my callback.

Read more comments on GitHub >

github_iconTop Results From Across the Web

getComputedStyled() causes a forced reflow #115 - GitHub
This change is a breaking change and in my opinion there are cases where focusable elements have zero size, like skip to main...
Read more >
"Force Reflow" in CSS transitions in Bootstrap - Stack Overflow
To me, it seems that in certain situations, the styles written to the dom are being buffered somewhere and not being flushed. That's...
Read more >
What is a Forced Reflow and How to Solve it? - Yonatan Kra
Force reflow (or Layout Reflow) is a major performance bottleneck. It happens when a measurement of the DOM happens after a DOM mutation....
Read more >
Transitioning Hidden Elements - Cloud Four
Hidden elements can not be transitioned since they're not in the document flow. However, we can get around this by forcing the document...
Read more >
Minimizing browser reflow | PageSpeed Insights
Here are some easy guidelines to help you minimize reflow in your web pages: Reduce unnecessary DOM depth. Changes at one level in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found