360 Secure SkillHub
360 安全技能中心

List Virtualization

核心功能是通过窗口化仅渲染可视区域,将DOM节点数从O(n)降至O(visible),让万级列表滚动接近60fps。典型场景为500+项的大列表,存在滚动掉帧、DOM过多或内存飙升问题,适配React/Vue等多框架,支持固定/可变高度、无限滚动、网格虚拟化等场景。需输入列表规模、项目框架约束,输出优化后的高性能列表,同时需注意SEO、原生搜索等限制。

bovinphang
bovinphang
热度 53.23
最近更新 2026-09-26 23:08:16
分类:开发依赖:读写文件应用场景:代码生成 / 代码审查 / 调试排错

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add fec-list-virtualization
Metadata
name
fec-list-virtualization
description
Use when optimizing or reviewing large lists, virtual scrolling, windowing, react-window, TanStack Virtual, variable-height rows, dynamic measurement, infinite scroll, grid virtualization, or scroll performance; Chinese triggers include virtual lists, large list optimization, scroll performance.

List virtualization optimization

Purpose

Only the visible area is rendered through windowing, which solves the problem of excessive DOM and stuck scrolling in large lists.

Procedure

  1. First confirm the list size and bottleneck: 500+ items, scrolling frame drops, too many DOM nodes, or memory surge before introducing virtualization.
  2. First follow the existing framework, dependencies and design system constraints of the project, and then select the library according to the scenario: React can consider react-window or TanStack Virtual; Vue/Solid/Svelte, dynamic measurement, grid or cross-framework scenarios give priority to TanStack Virtual; the legacy react-virtualized is only maintained and not added.
  3. Clarify item size, overscan, container height, key, rolling container and resize behavior.
  4. Separate data paging and DOM virtualization during infinite scrolling; data acquisition can be combined with the data acquisition workflow.
  5. Verify DOM node count, scrolling FPS, keyboard/screen reader experience, and Ctrl+F/SEO limitations.

Detailed reference

Load references/virtualization-patterns.md when it comes to the need for virtualization, library selection, fixed height, variable/dynamic height, infinite scrolling, grid virtualization, and performance considerations.

Constraints

  • SEO key content doesn’t exist only in dummy items.
  • Browser native Ctrl+F cannot search for unmounted items.
  • The Row root element must transparently transmit the style/measure ref provided by the virtual library.
  • If overscan is too high, memory will be wasted; if overscan is too low, the screen will be white.
  • Dynamic height measurement to handle ResizeObserver and layout jitter.

Expected Output

The scrolling of the 10,000+ item list is close to 60fps, the number of DOM nodes is stable within the visible area and buffer range, and the memory is reduced from O(n) to O(visible).