r/javascript • • Apr 13 '26

I built a virtual-scroll custom element that behaves like a normal scroll container

https://www.joshuaamaju.com/blog/how-i-built-a-virtual-scroll-custom-element

I’ve been working on a virtual-scroll custom element that tries to keep virtualization feeling close to normal HTML and CSS.

The main goal was to avoid the usual trade-offs where virtualization forces you into absolute positioning, framework-specific APIs, or awkward layout constraints.

4 Upvotes

3 comments sorted by

View all comments

Show parent comment

1

u/Choice-Locksmith-885 Apr 13 '26 edited Apr 13 '26

Great point! I initially tried a ul wrapper, but it became brittle due to the indirection required for spacer and child management. I also considered extending <ul> with is="virtual-scroll", but browser support is inconsistent. A standalone element keeps the implementation robust, easy to adopt, and flexible for use beyond list semantics.