Working on an additional PR now that adds a _bit_ more complexity but gains a ~15% perf boost in Chrome and ~36% in Firefox. It relies on detecting when the `content-visibility: auto` state changes and using the old `<img data-src>` trick to set the `src` in that case. https://github.com/nolanlawson/emoji-picker-element/pull/449
A bit of extra code, but still not as gnarly as a full virtual list!
Of course there's no way that rendering 40k DOM nodes (even with all these optimizations) will be as performant as a real virtual list, but… I'm interested to see how far I can take this with just some simple browser APIs.
With emoji-picker-element I really wanted to strike the balance between perf and simplicity, keeping bundle size low and not going overboard with complex optimizations.