wilsonpage / fastdom

Eliminates layout thrashing by batching DOM measurement and mutation tasks
6.83k stars 240 forks source link

Should this be used when mutating elements not attached to the document? #127

Closed Ambient-Impact closed 2 years ago

Ambient-Impact commented 2 years ago

If I'm creating elements and manipulating them, do the manipulations benefit from being wrapped in a FastDom callback if the element is not yet attached to the document, or does it make no difference? Actually inserting the element into the document would obviously be wrapped in a FastDom callback in both cases.

wilsonpage commented 2 years ago

No, fastdom only benefits elements that are in the render tree.

On Sat, 9 Oct 2021, 15:37 Matei Stanca, @.***> wrote:

If I'm creating elements and manipulating them, do the manipulations benefit from being wrapped in a FastDom callback if the element is not yet attached to the document, or does it make no difference? Actually inserting the element into the document would obviously be wrapped in a FastDom callback in both cases.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/wilsonpage/fastdom/issues/127, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZFB5BUIG5VKZ2IHWIOHLUGBHR3ANCNFSM5FVLQCYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Ambient-Impact commented 2 years ago

Good to know, thanks! Also thanks for the awesome library. Just getting started integrating it into my front-end stuff lately.