I need to do heavy DOM manipulations on the whole document of webpages in an Add-On I write. I would like to minimize the reflows so only one reflow happens for all my manipulations. Removing the body element, doing the manipulations and then inserting it again is not an option because this reevaluates all <script>
elements. Currently I set visibility of the body to 'none'
before the manipulations and restore the value of display after. I'm not sure if this is teh best way to deal with this, though.
Is there a better way? Of course it could be Firefox specific code. After all it's a Firefox Add-On.
Gecko is actually pretty good at suppressing unnecessary modifications on its own (i.e., you may well be better off not messing with it), except when, in between the many modifications you're making, you're also requesting information that requires layout to be up-to-date (such as element positions or sizes, getComputedStyle, etc.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With