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.

Performance: Could we somehow group layout actions?

See original GitHub issue

Detects are currently free to cause layout reflows whenever they like – which can be a lot, as demonstrated by @hexalys here: https://twitter.com/hexalys/status/432827905307983873

Is there some way we could cleverly group these together to reduce the number of reflows?

e.g. testStyles() could just register the styles it needs to test against, then when all detects have been run through, the elements & styles for all detects using testStyles() are added to the DOM at once, and their callback functions are then executed in turn.

Side effects:

  • The call to Modernizr.addTest() for these detects would have to consistently appear within the callback function – as testStyles() itself would no longer have a return value – but many already do this
  • Rather than always using a #modernizr element, each detect would have to have its own namespace, e.g. #modernizr1, #modernizr2 etc
  • We’d have to be careful to ensure this all still happens synchronously, but I think that’s doable

Issue Analytics

  • State:open
  • Created 10 years ago
  • Comments:21 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
ryanseddoncommented, Feb 27, 2017

I still think it would be interesting to try window.flushTests() in a requestIdleCallback as you still want to avoid running it if the thread is doing more important stuff.

0reactions
ryanseddoncommented, Feb 27, 2017

Amazing this is great stuff @aFarkas.

I just did a test with requestIdleCallback on a local copy of nytimes by remapping Modernizr.testStyles to _ => requestIdleCallback(injectElementWithStyles) I have a timeline here but it’s hard to dig into what it’s doing.

I think your idea has a lot more promise (pun intended).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Force Immediate Layout Update - Unity Forum
I 've been searching for a way to force the layout groups to update immediately, so that I can perform layout-related calculations all...
Read more >
How to Use GroupLayout - Oracle Help Center
GroupLayout works with the horizontal and vertical layouts separately. The layout is defined for each dimension independently. You do not need to worry...
Read more >
Measuring Cumulative Layout Shift - Request Metrics
Cumulative Layout Shift (CLS), sometimes known as jank, is a measurement of how much elements move due to late-rendered content. You can think...
Read more >
Chapter 4. Organizing the Page:Layout of Page Elements
Page layout is the art of manipulating the user's attention on a page to convey meaning, sequence, and points of interaction. If the...
Read more >
Team Building Games, Training, Ideas and Tips - BusinessBalls
Using and planning team-building activities. People are best motivated if you can involve them in designing and deciding the activities - ask them....
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