In this episode, we dive into the challenge (and probably the pain) of, no joke, rendering one million items on a web page. To start, we try the straightforward approach—just creating an array of a million and mapping through it in the DOM—which, as you might expect, quickly pushes the browser to its limits and ends up locking everything up. (Don't worry, we kill it before things get disastrous!)
From here, we pivot to a much smarter technique: using a virtual scroller component. The key idea is to only render the items that are actually visible in the viewport, instead of the whole million at once. We set up some basic styles, polish up the layout, and wire in vue-virtual-scroller
to handle this more efficiently. After hooking up the basics, you’ll see that we can suddenly scroll through a ridiculous number of items smoothly—no more browser crashes!
Finally, we talk about making sure each list item has a unique ID (for state tracking and Vue’s internal optimizations), and set up the groundwork for the next big step: showing all these (eventually interactive) checkboxes in a grid instead of just a long column. Stay tuned for that—things get a little more complex from here!