Skip to content

perf(editor): move optional modules off the startup payload - #291

Merged
chaxus merged 5 commits into
mainfrom
perf/editor-startup-payload
Oct 24, 2026
Merged

chaxus merged 5 commits into
mainfrom
perf/editor-startup-payload

Conversation

@chaxus

@chaxus chaxus commented Oct 24, 2026

Copy link
Copy Markdown
Member

Summary

The editor's static startup graph (the entry chunk plus its modulepreload links) shrinks from 1102 KB to 866 KB raw, and from 350 KB to 281 KB gzip, about 20% less. Two optional modules moved behind the point where they are first used:

  • WebMCP get_document_text: lib/web-mcp.ts imported lib/agent-plugin/tools.ts at the top of the file, which pulled in the whole agent tool layer and marked on every editor load. The tool is now imported inside its handler and still shares the panel's implementation. Saves 107 KB raw.
  • PWA install element: index.ts imported @khmyznikov/pwa-install up front, but only mounted it from a 1 s timer. It is now imported inside that timer. Saves 129 KB raw.

Both chunks remain in the offline precache: bin/offline-assets.mjs follows dynamic imports from entries, and I checked that APP_ASSETS_TO_CACHE lists tools-*.js and pwa-install.es-*.js.

Also adds pnpm run clean:e2e, which removes the dist-e2e-* / test-results-* / playwright-report-* directories that E2E_PORT runs leave behind. Nothing removed them before.

Commits

  1. perf(webmcp): dynamic import of the tool layer
  2. perf(editor): dynamic import of pwa-install
  3. test(e2e): editor-startup-payload.spec.ts
  4. chore(e2e): clean:e2e script
  5. docs(perf): exploration record, CHANGELOG, CLAUDE.md (WebMCP rule 5 corrected, spec count and table)

Tests and reverse validation

test/e2e/editor-startup-payload.spec.ts fetches every module script and modulepreload URL from the served editor.html and checks that none contains a probe string unique to a deferred module. A second case checks that <pwa-install> is still defined and mounted.

  • With both source changes reverted, the payload case fails on the agent-tool probe.
  • With only index.ts reverted, it fails on the PWA probe.
  • The mount case passes in all three states, as intended.

Run locally:

  • editor-startup-payload + webmcp + app-smoke E2E: 12 passed
  • pnpm run lint:ts: passed
  • format:check: passed
  • Unit tests web-mcp, workflow-contract, offline-assets-build, hosting-contract: 105 passed

I did not run the full E2E suite or the Pages/Docker configs locally; CI covers them. An independent subagent review found no blocking issues, and its three minor notes are addressed.

Details: docs/explorations/2026-10-24-editor-startup-payload.md.

🤖 Generated with Claude Code

chaxus and others added 5 commits October 24, 2026 13:04
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying document with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7c5e489
Status: ✅  Deploy successful!
Preview URL: https://d9d20115.document-7hm.pages.dev
Branch Preview URL: https://perf-editor-startup-payload.document-7hm.pages.dev

View logs

@chaxus
chaxus merged commit 47ee1d3 into main Oct 24, 2026
19 checks passed
@chaxus
chaxus deleted the perf/editor-startup-payload branch October 24, 2026 07:50
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