Skip to content

fix(perf): cut client bundle, image and prefetch weight / 减少客户端代码、图片与预取体积 - #1550

Merged
adibarra merged 1 commit into
masterfrom
fix/client-bundle-weight
Oct 29, 2026
Merged

adibarra merged 1 commit into
masterfrom
fix/client-bundle-weight

Conversation

@adibarra

@adibarra adibarra commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part 6 of the stack split from #1530. Review and merge in order. CI only runs on PRs that target master, so each layer was verified locally; the combined change passed full CI on #1530.

Stack (merge in order):

  1. fix(next): stop the image optimizer hanging after a cancelled request / 修复请求取消后图片优化器卡住的问题 #1545 Next image optimizer patch
  2. feat(api): negotiate compression, add ETag/304 and stale-while-revalidate purges / API 协商压缩,支持 ETag/304 与 stale-while-revalidate 失效 #1546 API response caching
  3. fix(dashboard): load benchmarks in parallel with availability / dashboard 的 benchmarks 与 availability 并行加载 #1547 Dashboard data waterfall
  4. fix(seo): social images, canonicals, titles, intros, structured data and sitemap / SEO:社交图片、canonical、标题、简介、结构化数据与 sitemap #1548 SEO metadata
  5. feat(seo): render compare, run, rankings, overview and blog index with ISR / compare、run、rankings、overview 与博客索引改用 ISR #1549 ISR for programmatic pages
  6. fix(perf): cut client bundle, image and prefetch weight / 减少客户端代码、图片与预取体积 #1550 Client bundle, image and prefetch weight ← this PR
  7. fix(ux): remove layout shifts and explain blocked legend toggles / 消除布局偏移并说明被禁用的图例切换 #1551 Layout shift and UX
  8. fix(analytics): correct pageviews, proxy PostHog and stop sending search text / 统计:修正 pageview、代理 PostHog 并不再发送搜索文本 #1552 Analytics pageviews and privacy
  9. feat(analytics): cover untracked interactions, add event context and standardize keys / 统计:覆盖未追踪的交互,补充事件上下文并统一键名 #1555 Analytics coverage

Blog posts shipped the whole dashboard bundle (+355 KB br) and served 222 MB of raw PNGs. Nav links prefetched dynamic routes. The root layout awaited a GitHub fetch that made every static page regenerate hourly.

  • Blog weight. HardwareChart loads lazily. MDX figures render through next/image with dimensions from figure-dimensions.json (regenerate with bun run blog:figure-dimensions). Optimized images are WebP with a one-day minimumCacheTTL.
  • Prefetching. Header, footer and tab nav use IntentPrefetchLink, which prefetches on hover or focus instead of on viewport entry.
  • Root layout. The GitHub star count loads in the browser with an hourly cache and failure backoff. The duplicate high-priority SVG preload is removed.
  • Server config. proxy.ts gets a config.matcher, public assets get cache headers, and the dead /api/cron cron is removed.
  • Initial render. Off-by-default ChartDisplay views load lazily. The landing hero renders without waiting for hydration, and the launch modal opens on idle.
  • ubenchX. The nav link targets /ubenchx/mem-bw, and /ubenchx becomes a redirect.

The decorative background can still be the desktop LCP element, and typography and KaTeX CSS are not scoped yet; both carry visual risk.

Validation details

Targeted Cypress (Chrome): blog 17/17, landing-performance 5/5, ubenchx 20/20, header component 26/26. On a Vercel preview of the combined change, a blog post loaded 15 Next chunks against 45 on dashboard pages. Lint, format, typecheck and the full unit suite pass on this layer.

AI model disclosure
  • Model/version: anthropic/claude-opus-5-5 (runtime-exposed identifier for the coordinating agent).
  • Role: audited the site, planned and integrated the change set, split it into this stack, and wrote commit and PR text.
  • Delegated agents (scout, worker and critic subagents) implemented slices, built the stack and ran verification under the same harness. Their exact model identifier was not exposed to the coordinating agent, so it could not be verified.
PR checklist
  • I have completed the AI model disclosure and kept it current
  • Added, changed, or removed filters, views, or pages include the matching API and inferencex-skills changes (no filters or views change)
  • New or changed indexable pages ship their /zh sibling
  • Changed Chinese copy follows the PR review checklist in docs/chinese-copy.md (Chinese maintainer review pending)
中文

本 PR 为从 #1530 拆分的 stack 中的第 6 部分,请按顺序审核与合并。CI 只在以 master 为目标的 PR 上运行,因此每一层都在本地验证;整体改动已在 #1530 上通过完整 CI。

博客文章此前会加载整个 dashboard 代码(+355 KB br)并输出共 222 MB 的原始 PNG;导航链接会预取动态路由;根布局等待 GitHub 请求,导致所有静态页每小时重新生成。

  • 博客体积。 HardwareChart 改为懒加载;MDX 图片改用 next/image,尺寸来自 figure-dimensions.json(用 bun run blog:figure-dimensions 重新生成);优化后的图片为 WebP,minimumCacheTTL 为一天。
  • 预取。 页头、页脚与标签导航使用 IntentPrefetchLink,改为悬停或聚焦时预取,不再在进入视口时预取。
  • 根布局。 GitHub star 数改在浏览器端加载,带一小时缓存与失败退避;移除重复的高优先级 SVG 预加载。
  • 服务端配置。 proxy.ts 增加 config.matcher,公共静态资源设置缓存头,并移除失效的 /api/cron 定时任务。
  • 首屏渲染。 ChartDisplay 中默认隐藏的视图改为懒加载;首页首屏不再等待水合,发布弹窗改为空闲时打开。
  • ubenchX。 导航链接指向 /ubenchx/mem-bw,/ubenchx 改为跳转。

装饰性背景仍可能是桌面端 LCP 元素,typography 与 KaTeX 样式尚未按路由拆分,两者都有视觉风险。

验证:定向 Cypress(Chrome):blog 17/17、landing-performance 5/5、ubenchx 20/20、header 组件 26/26。在整体改动的 Vercel preview 上,博客文章加载 15 个 Next 代码块,dashboard 页面为 45 个。本层的 lint、格式、类型检查与完整单元测试均通过。

AI 模型使用说明:协调 agent 使用 anthropic/claude-opus-5-5(运行环境提供的标识),负责审计、规划与整合改动、拆分 stack 以及撰写提交与 PR 文本;委派的子 agent 在同一环境中实现各部分、构建 stack 并运行验证,其确切模型标识无法获取,因此无法确认。


Note

Medium Risk
Broad performance refactors across blog rendering, root layout, middleware matching, and lazy-loaded dashboard views; wrong matcher or missing figure dimensions could break images or redirects, but no auth or data-path changes.

Overview
This PR reduces what every page loads: blog and dashboard UI are split and deferred, images go through the optimizer, and nav no longer prefetches heavy routes until the user shows intent.

Blog and MDX. <Figure> images with entries in figure-dimensions.json render via next/image (WebP, responsive srcset, fixed dimensions, eager/high priority only for the first figure). A new blog:figure-dimensions script and manifest keep sizes in sync; tests fail if a figure is missing. HardwareChart is dynamically imported so posts that do not use it skip the dashboard bundle. Themed figures pick up optimizer srcSet in pre-hydration bootstrap.

Navigation and layout. Header, footer, and dashboard tab links use IntentPrefetchLink (prefetch on hover/focus/touch, not in-viewport). GitHub star counts move from a blocking server fetch in the root layout to a client hook with localStorage TTL and failure backoff; the high-priority decorative SVG preload is removed. The root layout is synchronous again.

Dashboard and landing. Off-by-default ChartDisplay views (table, GPU-over-time, power timeline, PowerX panels) load with next/dynamic. The landing hero and intro render without Reveal delay wrappers; the TPUv7 launch modal trigger switches from immediate to idle after load.

Routing and caching. /ubenchx redirects to /ubenchx/mem-bw (nav links updated; standalone redirect pages removed). next.config adds one-day cache headers for public assets, WebP-only optimized images, and documents proxy scope. proxy.ts gets an explicit config.matcher so middleware runs only on API routes, embeds, legacy inference query redirects, and compare canonicalization—not static pages or RSC compare navigations. The unused Vercel /api/cron job is dropped.

Docs, Cypress, and unit tests are updated for optimizer URLs, ubenchX hrefs, and the new figure workflow.

Reviewed by Cursor Bugbot for commit 5e40569. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
inferencemax-app Ready Ready Preview Oct 29, 2026 6:20am UTC

Request Review

@adibarra
adibarra force-pushed the feat/isr-programmatic-pages branch from e5360b6 to 06a3d3f Compare October 29, 2026 02:06
@adibarra
adibarra force-pushed the fix/client-bundle-weight branch from eff686b to c090b03 Compare October 29, 2026 02:06
@adibarra
adibarra force-pushed the feat/isr-programmatic-pages branch from 93468d9 to ce85fca Compare October 29, 2026 05:54
@adibarra
adibarra force-pushed the fix/client-bundle-weight branch from c090b03 to aade255 Compare October 29, 2026 05:54
@adibarra
adibarra force-pushed the fix/client-bundle-weight branch from aade255 to 4023e11 Compare October 29, 2026 06:03
@adibarra
adibarra force-pushed the fix/client-bundle-weight branch from 4023e11 to 96b2e47 Compare October 29, 2026 06:15
HardwareChart and the off-by-default chart views (table, GPU over time,
power timeline, PowerX panels) load on first use. MDX figures render
through next/image at sizes recorded in figure-dimensions.json, written by
a new generator script, and the image optimizer serves WebP with a one-day
minimum TTL. Header, footer and tab links prefetch on intent. The GitHub
star count is fetched by the browser, so the root layout no longer awaits
it, and the duplicate SVG preload is gone. The proxy runs only on paths
that need it, public files get daily Cache-Control, and the unused Vercel
cron is removed. The landing hero renders outside Reveal, and nudges gain
an idle trigger. The ubenchX nav link targets /ubenchx/mem-bw, which
/ubenchx now redirects to.

中文:HardwareChart 与默认关闭的图表视图(表格、GPU 时间序列、功耗时间线、
PowerX 面板)改为首次使用时加载。MDX 配图通过 next/image 按
figure-dimensions.json 记录的尺寸渲染,该文件由新脚本生成,图片优化器输出
WebP,最短缓存一天。页头、页脚与标签页链接按意图预取。GitHub star 数改由
浏览器获取,根布局不再等待该请求,并移除重复的 SVG 预加载。proxy 只在需要的
路径上运行,public 文件使用按天缓存的 Cache-Control,并移除未使用的 Vercel
cron。首页主视觉不再包在 Reveal 中,nudge 新增 idle 触发方式。ubenchX 导航
指向 /ubenchx/mem-bw,/ubenchx 重定向到该页。
Base automatically changed from feat/isr-programmatic-pages to master October 29, 2026 06:18
@adibarra
adibarra force-pushed the fix/client-bundle-weight branch from 96b2e47 to 5e40569 Compare October 29, 2026 06:19
@adibarra
adibarra merged commit 0f1f236 into master Oct 29, 2026
33 checks passed
@adibarra
adibarra deleted the fix/client-bundle-weight branch October 29, 2026 06:24

This branch was successfully deployed

1 active deployment
Preview — 5e40569c Deployed Oct 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant