Reflow / repaint detection: Possible today? Possible in the future?
Asked Answered
C

1

6

I'd like to know if there's a reliable way on modern web browsers to detect document reflows and/or repaints, or if there's any pressing interest for such a thing that might put it in a W3 spec.

I would also like to know how it can be accomplished at all using vendor-specific tricks (e.g. Mozilla apparently has a MozAfterRepaint event,) if it's not possible in a standard or cross-browser way.

Thanks.

Colemancolemanite answered 15/4, 2014 at 18:12 Comment(2)
There is no real reason to capture that event, as it is unpredictable since frame rates vary. Use requestAnimationFrame to get closer to the redraw cycle.Marv
possible dupe of #7006652Chequered
M
0

You can't measure accurately but you can predict by looking through any javascript which is a getter or setter/changer of styling, animating, adding/removing classes on elements. This can be done by using javascript to ajax all the javascript on the page to get the javascript strings, and then use regular expressions to detect where they are. Create an object of all the method names you find that do this.

If you want to capture it in realtime, you could use a combination of the above, and currying all the methods on the page to call your own mediator to marry it up with your object reference above.

Merrow answered 3/5, 2015 at 15:50 Comment(2)
Static code analysis to detect repaints and/or reflows? Who would go that far? Besides, that would only yield code points that might cause repaints and/or reflows, but you'd still have to somehow predict when such code points are reached. In other words, you'd have to modify the code to add event triggers. And besides still, JavaScript isn't the only thing that can cause repaints / reflows. Sorry, but this is an insane proposition.Saccharase
I would go that far because I believe in better debugging and better performance and freedom from bad frameworks. Once you know what causes reflows then thats the work done. Javascript can detect the css on the page - computed aswell. You have complete access to the Dom. It is possible but I didn't say it was going to be easy. it depends on the experience of the developer.Merrow

© 2022 - 2024 — McMap. All rights reserved.