The AI cost of JavaScript frameworks
- ID: 761e5e0b
- 原文链接: https://nolanlawson.com/2026/10/28/the-ai-cost-of-javascript-frameworks
- 作者: Nolan Lawson
- 日期: 2026-10-28
- 更新: N/A
- 分类: coding
- 来源类型: article
- 标签: coding-agents, benchmark, web-frameworks, lighthouse, cost
- 质量评分: 4/5
- 抓取时间: 2026-11-02T12:22:52Z
中文导读
Agent 时代前端框架选型还靠"氛围"吗?Nolan Lawson 自建基准:让 Claude Code(Opus 5.5,high effort)按统一的 Pokemon 应用规格,用 12 个 JS 框架/元框架各构建 5 次,用基于可访问性树的规格符合度套件防作弊,再比较成本、token、耗时、代码量与 Lighthouse。结果显示性能/可访问性得分普遍饱和(97–100),真正的分化在成本与体积:Hono+htmx 每次构建中位 $2.67 最便宜,Angular $4.97 最贵(且 17.2 分钟、9.76M token);JS 传输量从 Astro 约 0 KiB 到 Next.js 约 142 KiB;代码量从约 1370 行到约 2009 行,直接决定后续维护的 token 开销。作者以此示范"用证据替代氛围",并怀疑当前各类 MCP/skills 可能弊大于利。
为什么值得关注
此前"某框架对 agent 更友好"的说法几乎都不带基准。这篇文章给出可复现的实验模板:同一规格、同一模型、每框架 5 次取中位数、符合度检查基于可访问性树以避免锁定特定 HTML 结构(有框架用 shadow DOM)。几个对工程实践有直接参考的发现:其一,Lighthouse 传统指标区分度有限,信号转移到 JS 字节数、TBT、LCP,MPA 系统性占优而 SPA 受罚(Qwik 是例外,按 SPA 路由却拿到 MPA 级 LCP);其二,代码量与 token 成本直接挂钩,Rich Harris 的"框架是整理思维的工具"在 agent 时代变成字面意义的维护成本问题;其三,各家 MCP/skills 实际被 agent 使用率参差(Next.js 的 skill 文件仅 1/5 次被读取,Nuxt 的 MCP 从未被用),作者怀疑这类工具链弊大于利;其四,Vanilla(Vite 裸项目)成本中位 $2.98,反而贵过 Hono+htmx/Astro/Nuxt 等多个框架,说明"有框架好过没有"。
关键信息
- 作者:Nolan Lawson
- 实验设计:12 个框架/元框架 × 各 5 次运行(Angular 两次未产出可测应用,代码量与性能指标取 3 次),Pokemon 应用规格 + 可访问性树符合度套件 + Lighthouse
- 工具设置:Claude Code 沙盒运行,各框架使用其官方 MCP/skills(如有),未指定 SSR/CSR 架构,禁止 Tailwind/Bootstrap 等组件框架,禁止预生成静态 HTML 作弊
- 成本中位数(每构建):Hono+htmx $2.67、Astro $2.76、Nuxt $2.82、Vanilla $2.98、Next.js $3.14、SvelteKit $4.28、Angular $4.97(方差大:React Router 中位贵约 $1,但最便宜样本 $2.82 仍低于 Hono 最贵样本 $3.19)
- 体积与性能:JS 字节数 Astro 约 0 KiB → Next.js 约 142 KiB;LCP 大体随 bundle 大小增长,MPA 占优(Next.js 方差大源于个别 app 未做图片懒加载);TBT 除 Next.js(71ms)/Angular(103ms)外都很小
- 代码量:Hono+htmx 约 1370 行 → Angular 约 2009 行;代码量影响后续编辑的 token 成本
- MCP/skills 使用率参差:Svelte MCP、Hono skill、React Router skill 5/5 被用;Angular MCP 3/5、Astro MCP 2/5;Next.js skill 文件仅 1/5、Nuxt MCP 0/5
- 作者观点:agent 时代仍可用证据做框架决策;怀疑现有 MCP/skills 弊大于利;基准已开源(github.com/nolanlawson/agent-framework-benchmark)
- 原文发布:2026-10-28
English Summary
Nolan Lawson built a benchmark to test whether JavaScript framework choice can be evidence-based in the agentic era. Claude Code (Opus 5.5, high effort) built the same non-trivial Pokemon app (list/search/filter over PokeAPI data) 5 times per framework across 12 frameworks/meta-frameworks (Next.js, Nuxt, SvelteKit, Astro, Qwik, SolidStart, TanStack Start, React Router, Angular, Gracile+Lit, Hono+htmx, Vanilla with Vite), each using its official MCP/skills where available, without steering architecture (SSR vs CSR) or performance work, and validated by a spec-conformance suite based on the accessibility tree to avoid mandating any HTML structure. Median build cost ranged from $2.67 (Hono+htmx) to $4.97 (Angular, 17.2 min, 9.76M tokens); SvelteKit, Gracile+Lit and Angular were most expensive, partly because agents repeatedly read migration guides or unfamiliar sources. Lighthouse Performance/Accessibility were nearly saturated (97-100), so the signal moved to JS bytes (Astro ~0 KiB vs Next.js ~142 KiB), TBT, and LCP, which broadly reward MPAs over SPAs (Qwik scores like an MPA despite client-side routing). LOC ranged from ~1370 (Hono+htmx) to ~2009 (Angular), and code size feeds the token cost of future edits. His conclusion: evidence-based framework decisions are still possible when typing code by hand is optional, and the current crop of MCPs/skills may do more harm than good. The benchmark is open-source on GitHub.
Obsidian Notes
- 内容获取路径:opencli-first。首次
opencli web read返回 Navigation rejected,原命令重试成功,全文以 markdown 落地(约 27KB)。 - 中文导读与关键信息锚定在抓取全文与条目既有摘要(summary_zh/summary_en),不引入文外数据。
- 现代站点生成器按
content/{entry.id}.md查找内容页;本文件写入 canonical content 目录,而不是openclaw/content/。