Virtual Scroll Plugin
The virtual-scroll plugin enables virtualized rendering for large option lists. Instead of rendering all options at once, only the visible options (plus a small buffer) are rendered in the DOM, dramatically improving performance for lists with thousands of items.
Usage
When to Use
| Option Count | Recommendation |
|---|---|
| < 500 | Standard rendering is fine |
| 500 - 2,000 | Virtual scroll recommended |
| 2,000+ | Virtual scroll strongly recommended |
| 10,000+ | Virtual scroll required |
Configuration
| Attribute | Description | Default |
|---|---|---|
data-plugin-virtual-scroll-height | Height of each option row in pixels | 36 |
data-plugin-virtual-scroll-buffer | Number of extra rows to render above/below the visible area | 10 |
With AJAX and Pagination
Virtual scroll works alongside AJAX pagination for the best performance with remote data:
Behavior
- The dropdown renders only the options currently visible in the scroll viewport
- Scrolling dynamically renders and removes option elements
- Search filtering works as normal — the filtered list is also virtualized
- Keyboard navigation (arrow keys) works seamlessly with virtualized options
WARNING
When using virtual scroll, all option rows must have a uniform height. Custom templates with variable-height content may cause rendering issues. Set data-plugin-virtual-scroll-height to match your tallest option.
Performance
Benchmarks with 10,000 static options:
| Metric | Without Virtual Scroll | With Virtual Scroll |
|---|---|---|
| Initial render | ~800ms | ~15ms |
| DOM nodes | 10,000+ | ~40 |
| Memory usage | ~45 MB | ~5 MB |
| Scroll performance | Janky | Smooth 60fps |