That's a really good idea. Definitely something to measure, but I suspect you're right.
Re:Show HN: HN Avatars in 357 bytes
by eyelidlessness on Tuesday March 15, 2022 @01:09AM
(#30681868)
If it turns out there’s some upper bound where caching canvases in memory becomes a problem (eg large threads become not paginated), it’s pretty trivial to build a cache around [Weak]Map and get the ~best of both worlds.
Personally I'd leave it created and stop observing the element instead, à la
Do you think (or know) that swapping observed node for canvas (potentially producing many canvases) is more expensive than keeping all observers and having smallest possible amount of canvases? (Maybe I'm biased towards saving CPU but saving RAM is better after all?)