Performance: Could we somehow group layout actions?
See original GitHub issueDetects 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 – astestStyles()
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:
- Created 10 years ago
- Comments:21 (18 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I still think it would be interesting to try
window.flushTests()
in arequestIdleCallback
as you still want to avoid running it if the thread is doing more important stuff.Amazing this is great stuff @aFarkas.
I just did a test with
requestIdleCallback
on a local copy of nytimes by remappingModernizr.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).