I have a page with a lot of components like charts and tables and I want to cache them by rendering them on a document fragment so that I can attach and detach the fragment to the real dom when it's in the viewport. Will it take the same memory as real dom or will there be any performance benefits? My current dom is taking a lot of memory because of the large no. of elements.
Asked
Active
Viewed 63 times
0
-
What have you tried so far? – evolutionxbox Apr 12 '21 at 10:35
-
I first tried adding and removing stuff from dom using intersection observer when they're visible in the viewport but rendering takes time because these are heavy components then I tried saving them as string and reattaching the string to the dom but then it'll lose the interactivity and doing manual rehydration is too much work. – Rohan Apr 12 '21 at 11:31
-
In mdn, it says the main benefit of using fragment is it prevents reflows when you do modifications but does it also save the memory or use the same amount of memory. – Rohan Apr 12 '21 at 11:32