Skip to content

perf: drop jschardet and the editor stack from startup payloads - #292

Merged
chaxus merged 6 commits into
mainfrom
perf/startup-payload-2
Oct 24, 2026
Merged

chaxus merged 6 commits into
mainfrom
perf/startup-payload-2

Conversation

@chaxus

@chaxus chaxus commented Oct 24, 2026

Copy link
Copy Markdown
Member

Summary

This is the second round of startup-payload fixes, after #291.

Page Before (main 47ee1d3a) After
/editor 866 KB raw / 280 KB gzip 537 KB raw / 163 KB gzip
/history 476 KB raw / 148 KB gzip 400 KB raw / 122 KB gzip

Counting #291 as well, the editor's startup graph has gone from 350 KB to 163 KB gzip. The figures are the static startup graph, summed per chunk from .vite/manifest.json.

jschardet (fixed upstream)

466 KB of the editor entry chunk's source was jschardet, though nothing in the app detects charsets statistically. It came from ranuts/utils/str.ts, which imports detect at the top. MessageCodec, used at startup by lib/events.ts, lives in the same file, and jschardet is CommonJS, so bundlers can't drop it.

Fixed in ranuts itself: chaxus/ran#443 moves the three functions that use jschardet into utils/charset.ts, and ranuts 0.5.1 is published with it. This PR upgrades ranuts and ranui to 0.5.1; ranui brings ranview 0.2.1, and the minimumReleaseAgeExclude pin follows. It also re-syncs the vendored ran-tokens.css and ranui-iife/* the same way bin/build.sh does.

The history page loaded the editor

/history imported formatRelativeTime from history/recovery, which imports lib/document, and the autosave preference from history/autosave, which imports the save pipeline. Both helpers are pure. They now live in history/relative-time.ts and history/preferences.ts, and setAutosaveEnabled behaves as before.

Commits

  1. build(deps): ranuts / ranui 0.5.1
  2. perf(history): history page no longer imports the editor stack
  3. test(e2e): startup payload spec covers jschardet and /history
  4. docs(perf): exploration record, CHANGELOG, CLAUDE.md note

Tests and reverse validation

editor-startup-payload.spec.ts now checks:

  • /editor: the agent tools, the PWA library and jschardet are absent.
  • /history: the save pipeline and jschardet are absent.

Reverse validation:

  • With ranuts pinned back to 0.5.0, the editor case fails on jschardet.
  • With the history page importing history/recovery and history/autosave again, the history case fails on the save pipeline.

Run locally:

  • lint:ts and format:check: passed.
  • Full unit suite: 6801 tests passed.
  • E2E, 56 tests passed:
    • editor-startup-payload, history-page, app-smoke, csv-encoding;
    • because of the ranui bump: main-site, embed-regression, autosave-recovery, entry-paths, agent-sidebar-layout, webmcp.

The full E2E suite and the Pages/Docker configs are left to CI. An independent subagent review found no blocking issues, and its two low findings are fixed.

Not in this PR

All seven languages' message tables (about 215 KB of source) load on both pages. Fixing that changes the synchronous t() contract of @ranuts/shared/i18n, so it needs its own decision.

🤖 Generated with Claude Code

chaxus and others added 4 commits October 24, 2026 17:02
ranuts 0.5.1 moves its jschardet-backed helpers out of utils/str.ts
(chaxus/ran#443). MessageCodec, used at startup by lib/events.ts, no longer
drags the 332 KB detector into the editor entry chunk; nothing here calls
the charset-sniffing helpers. ranui 0.5.1 brings ranview 0.2.1, so the
minimum-release-age exclusion follows it, and the vendored token sheet and
component IIFEs are re-synced the way bin/build.sh does on every build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page imported formatRelativeTime from history/recovery (which imports
lib/document) and the autosave preference from history/autosave (which
imports the save pipeline), so /history loaded the editor's document chunk
to render a list. Both helpers are pure and now live in history/relative-time
and history/preferences; setAutosaveEnabled still writes the preference and
stops the running session.

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

cloudflare-workers-and-pages Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Deploying document with  Cloudflare Pages  Cloudflare Pages

Latest commit: e3333c1
Status: ✅  Deploy successful!
Preview URL: https://0c1df4f1.document-7hm.pages.dev
Branch Preview URL: https://perf-startup-payload-2.document-7hm.pages.dev

View logs

chaxus and others added 2 commits October 24, 2026 18:52
ranui 0.5.1 writes the portal layer inline as
var(--ran-dropdown-host-z-index, var(--ran-z-dropdown, 1100)), so the plain
z-index rules on .agent-speech-popover and r-dropdown[role='listbox'] lost to
it and both portals fell under the assistant panel (z-index 10000): the
dictation privacy hint could not be hovered, and settings select lists drew
behind the panel. Set the property ranui reads instead. A new spec checks a
select opened in the panel is the topmost element; it and the dictation case
fail with the old rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chaxus
chaxus merged commit f7578aa into main Oct 24, 2026
19 checks passed
@chaxus
chaxus deleted the perf/startup-payload-2 branch October 24, 2026 11:45
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