virtual-list
What it does
This skill explains virtual scrolling, where only items near the visible area are drawn on the page. It covers lists with fixed and changing row heights. It is for developers showing very long lists in a web page.
When to use it
- ✓When a web list has thousands of items and the page slows down.
- ✓When items have a fixed height and you want a simple fast list.
- ✓When items have different heights and you need a list that still stays fast.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/virtual-list/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Can you make a list of ten thousand items on my web page that scrolls smoothly?”
5 new skills a week. 1 minute to read.
How it works
The list keeps a small pool of reusable page elements and draws only the rows in view, plus a few extra above and below to avoid flicker.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Virtual List Implementation Skill
Overview
This skill teaches you how to implement a high-performance virtual scrolling list component that can efficiently render thousands or millions of items by only creating DOM nodes for visible items plus a small buffer.
Analysis of Reference Implementation
The VirtualList component from /worldmonitor/src/components/VirtualList.ts demonstrates professional-grade virtual scrolling with the following patterns:
1. Chunk-Based Rendering Pattern
The implementation uses two complementary strategies:
VirtualList (Fixed-Height Items)
- Item Pool Management: Maintains a pool of reusable DOM elements (
PooledElement[]) - Viewport Calculation: Calculates visible range based on
scrollTop,itemHeight, and viewport dimensions - Overscan Buffer: Renders extra items above/below viewport (
overscanparameter) to prevent flickering during scroll
WindowedList (Variable-Height Items)
- Chunk-Based Approach: Divides items into chunks (default 10 items per chunk)
- Lazy Chunk Rendering: Only renders chunks that are visible or within buffer range
- Placeholder Elements: Creates placeholders for all chunks upfront, renders content on-demand
2. Scroll Listener Optimization
private handleScroll = (): void => {
if (this.scrollRAF !== null) return;
this.scrollRAF = requestAnimationFrame(() => {
this.scrollRAF = null;
if (!this.isDestroyed) {
this.updateVisibleRange();
}
});
};
Key Optimizations:
- RequestAnimationFrame Throttling: Prevents multiple renders in same frame
- Passive Listeners:
{ passive: true }improves scroll performance - Debounce Check: Guards against duplicate RAF calls
- Cleanup Check: Prevents rendering after destruction
3. DOM Recycling Strategy
The implementation uses a sophisticated two-pass recycling algorithm:
Pass 1: Identify Reusable Elements
for (const pooled of this.itemPool) {
if (pooled.currentIndex >= visibleStart && pooled.currentIndex < visibleEnd) {
usedIndices.add(pooled.currentIndex);
}
}
Pass 2: Recycle and Reassign
while (poolIndex < this.itemPool.length) {
const pooled = this.itemPool[poolIndex]!;
if (pooled.currentIndex < visibleStart || pooled.currentIndex >= visibleEnd) {
// Recycle this element
if (this.onRecycle) {
this.onRecycle(pooled.element);
}
pooled.currentIndex = i;
this.renderItem(i, pooled.element);
pooled.element.style.transform = `translateY(${i * this.itemHeight}px)`;
poolIndex++;
break;
}
poolIndex++;
}
Benefits:
- Minimizes DOM manipulation
- Reuses existing elements when possible
- Allows cleanup of event listeners via
onRecyclecallback - Uses
transform: translateY()for GPU-accelerated positioning
4. Performance Optimizations
Spacer Elements for Virtual Height
this.topSpacer.style.height = `${visibleStart * this.itemHeight}px`;
this.bottomSpacer.style.height = `${Math.max(0, (this.totalItems - visibleEnd) * this.itemHeight)}px`;
- Creates illusion of full list height without rendering all items
- Maintains accurate scrollbar size and position
Skip Unnecessary Updates
if (visibleStart === this.visibleStart && visibleEnd === this.visibleEnd) {
return;
}
CSS Positioning Strategy
element.style.position = 'absolute';
element.style.top = '0';
element.style.left = '0';
element.style.right = '0';
element.style.transform = 'translateY(-9999px)'; // Hide off-screen
- Absolute positioning for precise control
- Transform for GPU acceleration
- Off-screen positioning instead of display:none (preserves element state)
ResizeObserver Integration
if (typeof ResizeObserver !== 'undefined') {
this.resizeObserver = new ResizeObserver(() => {
if (!this.isDestroyed) {
this.updateVisibleRange();
}
});
this.resizeObserver.observe(this.viewport);
}
- Automatically recalculates visible range when viewport resizes
- Progressive enhancement (checks for browser support)
Complete TypeScript Implementation Template
Below is a simplified but fully functional virtual list implementation that you can drop into any vanilla TypeScript project:
/**
* SimpleVirtualList - A simplified virtual scrolling implementation
*
* Usage:
* ```typescript
* const virtualList = new Sim
FAQ
What is virtual scrolling?
It is a method that draws only the items you can see, instead of creating every item on the page.
What is the difference between the two list types?
One is for items with the same height, and the other is for items with changing heights, drawn in chunks.
Does scrolling stay smooth?
The skill uses a timed update on scroll so the page does not do extra work on every small movement.
Details
Original description by the author
Implement efficient virtual scrolling for rendering large lists with DOM recycling, chunk-based rendering, and performance optimizations
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #13091
- License
- MIT
- Updated
- 11/1/2026
Comments
- …
More skills from this repository
agentpilot
7.8kHelps your agent improve a project step by step by preparing a task and running the AgentPilot loop that proposes, tests and scores changes.
openspace
7.8kHelps your agent set up OpenSpace, a tool that stores and fetches agent skills, and connect it to your AI app through MCP.
rsi-arena
7.8kHelps your agent set up and run standard AI benchmark tests, such as AIME and Terminal-Bench, to compare different improvement methods.
experiment-guide
7.8kHelps your agent plan small experiments, read their results and record findings while it investigates how to improve a program.
Similar skills
angular-developer
280kHelps your agent create Angular code and give project structure advice. Useful for starting new projects, creating code parts, or improving performance and accessibility.
frontend-a11y
280kHelps your agent make web interfaces accessible to everyone. It ensures websites and apps work well with screen readers and keyboard navigation.
frontend-patterns
280kHas your agent apply modern patterns in frontend development. It optimizes performance, manages state, and follows best practices in React and Next.js.