dom-size
它能做什么
这项技能检查页面包含多少 HTML 元素,以及它们嵌套得有多深。适合页面感觉缓慢或臃肿的开发者。
适用场景
- ✓当包含长列表的页面滚动变得缓慢时。
- ✓当浏览器审计报告页面结构非常庞大时。
- ✓当页面有许多没有实际作用的包装元素时。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/dom-size/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“你能检查我的页面是否有太多 HTML 元素吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会使用浏览器工具测量元素总数和嵌套深度。然后建议删除不必要的包装元素,并把长列表分成更小的部分来显示。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Reduce DOM size and complexity
An excessive DOM size increases memory usage, slows down style calculations, and makes layout reflows more expensive, leading to poor interaction performance.
Quick Reference
- Keep total DOM nodes below 1,500
- Avoid deep nesting (maximum depth < 32)
- Use virtualization for long lists of elements
Check
Check the total number of DOM nodes and the maximum DOM depth using Lighthouse or Chrome DevTools.
Fix
Simplify the HTML structure, remove unnecessary wrapper elements, and implement virtualization for large lists.
Explain
Explain the performance impact of a large DOM tree on memory and rendering speed.
Code Review
Review the routes, assets, and loading behavior that affect Reduce DOM size and complexity. Flag exact files, requests, or rendering steps that add unnecessary network, CPU, or layout cost, and describe the measurement method used to confirm the issue.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/performance/dom-size
常见问题
多少个元素算太多?
这项技能建议把元素总数保持在约 1500 个以下,嵌套层级保持在约 32 层以内。
什么是虚拟化?
指只显示屏幕上可见的列表项,从而保持页面轻量。
如何衡量这个问题?
这项技能建议使用 Lighthouse 或 Chrome DevTools。
详情
作者的原始描述
Use when auditing slow page loads, heavy assets, or rendering delays related to Reduce DOM size and complexity. Verify the actual bottleneck in DevTools, Lighthouse, or field data before recommending changes.
热度
- GitHub 星标
- 75k
- 排名
- #2821
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。