Description
Summary
After #732, _app is still 681 kB, and Home loads 952 kB of first-load JS. Most of it is editor code Home never uses: ProseMirror, Tiptap, Yjs, Virtuoso, the sheet frame and DiceBear. Four import chains and one module-load cost (C5) pull it in. This issue cuts them one step at a time. It also starts the pad's editor chunks sooner, so the pad does not get slower. It also owns the CI bundle budget (step 6).
Benchmark
| Field | Value |
|---|---|
| Metric | Home JS over the wire, in bytes (exact). Route table first-load JS for /, /[...slugs] and _app, in kB. Pad guard: t2, ms from navigation start to the first sync step 2 frame received on the collab WebSocket. |
| Before | Home JS: 965,119 B (0b302b222, 2026-11-11 11:13Z, #732 comment of 11:20Z). Route table: 952 / 925 / 681 kB (0b302b222 deploy log, build:ci, read 2026-11-11). Home Lighthouse is context only. The 11:13Z set: LCP 7.35 s (7.26–7.80), TBT 254 ms (251–272), FCP 1.33 s (1.22–1.56), TTFB 211 ms, n = 5. The 17:14Z rerun on the same commit: TBT 308 ms (287–330), FCP 1.15 s, TTFB 115 ms (#732 close comment). The maintainer takes a fresh n = 5 Home before on the day of step 3, after the #741 step 3B deploy, with TTFB recorded. Pad timeline: not measured yet: agent in the repo (local) and maintainer (production /demo) take it before step 3. |
| After | not measured yet |
| Confounds | #741 step 3B (GA off), #738, #734 step 1, #751, #736 and #747. Take each before and after pair with none of these deployed in between. Record the deploy hash of every run. Re-take the before if one lands. |
| Condition | Home: production, Lighthouse 12.8.2, Chrome 157, default mobile (simulated 150 ms RTT, 1,638.4 Kbps, 4x CPU), the #732 laptop, n = 5, median (min–max). Pad: packages/document-swarm/src/pad-timeline.ts (method below), cold context, 1440 × 900. Lighthouse is never used on a pad. |
| How to run | Route table: build:ci. Home bytes: the #732 byte method (each <script src> in Home's HTML, gzip, summed). Pad: bun packages/document-swarm/src/pad-timeline.ts --url <url> --runs 10. |
| Pass rule | Each step: every route-table value smaller or equal; /[...slugs] must not rise. Step 3: Home wire bytes fall by at least 60 % of the / route-table drop. Pad gate: see step 3. Revert a step that fails its gate. |
| Guard | Pad open time (step 3 gate) and the UX checks below. Step 5: a test error still carries contexts.trace.trace_id, which #751 and #752 count by. |
| Owner | Agent in the repo: steps 1-6, route tables, the local timeline. Maintainer: production Lighthouse, the production timeline, the phone checks, and the budget limits. |
| Claim | "Home's JavaScript over the wire fell from 965,119 B to X B (gzip) in v2.3.7, and pad first sync stayed within % of before (median, n = 10, production /demo, simulated slow link)." |
| Step | Row | Before | After (pass) | Condition | n |
|---|---|---|---|---|---|
| each | Route table /, /[...slugs], _app |
952 / 925 / 681 kB (0b302b222) |
each smaller or equal; /[...slugs] must not rise |
build:ci |
exact |
| 3 | Home JS over the wire | 965,119 B (0b302b222) |
falls by at least 60 % of the / route-table drop |
#732 byte method, gzip | exact |
| 3 | Home LCP, TBT, FCP | fresh n = 5 set on the day of step 3 (the 11:13Z and 17:14Z sets are context) | LCP and TBT within the A/A gate (step 3); record the LCP element and its render delay | Home condition | 5 |
| 3 | Scratch pad: t1 WebSocket open, t2 first sync | not measured yet | medians at most before + 50 ms; max not worse by more than 10 % | Pad condition, local production build | 10 cold |
| 3 | /demo: t2 first sync, t4 throttled fill |
not measured yet | t2 median at most before + 5 % | Pad condition, production, load only | 10 cold |
| 3 | First DocumentPage chunk request starts before _app ends |
not measured yet | record yes / no per run (the preload fallback targets 10 of 10) | Resource Timing, same runs | 10 |
| 5 | Test error carries contexts.trace.trace_id |
yes | yes | local, dummy DSN | 1 |
| 6 | Routes guarded by a CI budget | 0 | 3 | build:ci; one deliberate red run |
exact |
Pad timeline method
Commit it as packages/document-swarm/src/pad-timeline.ts.
- Playwright Chromium. A new context per cold run: no HTTP cache, no service worker, no IndexedDB. Viewport 1440 × 900.
- CDP
Network.emulateNetworkConditions: latency 150, download 209,715 B/s, upload 86,400 B/s.Emulation.setCPUThrottlingRate: 4. - CDP throttling may not delay WebSocket frames. So the script checks it first. It times one known first-sync frame against its byte size. If the frame arrives faster than 209,715 B/s allows, CDP did not throttle it. Then route the collab socket through a TCP proxy like the Show "synced" only after the server confirms the edit #736 one, at the same latency and rate. Print which path ran.
- Marks from navigation start:
- t1:
Network.webSocketCreatedfor the collab host. - t1b: the first received frame on it, the auth reply.
- t2: the first received frame on the collab socket that decodes as a sync message (outer type 0, sync step 2). The provider sends its token first, then starts sync (
@hocuspocus/provider3.4.4), so the first frame is not a sync message. - t3: skeleton gone and editor ready.
- t4 throttled fill: heading count stable for 2 s, under the CDP throttle. It is not the house pad fill time, which comes from
fillcheck.ts. Never compare the two.
- t1:
- Also record the JS
encodedDataLengthbefore t1. From Resource Timing, record whether the firstDocumentPagechunk request starts before the_appresponse ends. - Discard a run that never fills, and re-run it.
- Output: median and range per mark.
- Local runs use a scratch pad that the script creates on the local stack and deletes after. Production runs only load
/demo. Nobody types into/demo. - Never compare pad timeline numbers with Home Lighthouse numbers. Lighthouse simulates its throttle; this script applies it.
- Ruled B, 2026-11-16: the script lives in
packages/document-swarm, which already hasplaywright1.64.1.
Cause (read from code)
| Cut | Chain into Home | Line |
|---|---|---|
| C1 | _app loads BottomSheet, which loads 14 sheet bodies statically, with the editor stack |
apps/webapp/src/pages/_app.tsx:6, :220; components/BottomSheet.tsx:1-29 |
| C2 | useProfileSync (every route) → the @api barrel → fetchLinkMetadata.ts → the whole hyperlink extension, for normalizeHref |
api/users/fetchLinkMetadata.ts:1; api/index.ts:8 |
| C3 | Settings constants import a Tiptap helper | components/settings/constants.ts:3 |
| C4 | CommandJump → historyShareUrl.ts → history/helpers.ts → Yjs and the transformer, for formatVersionDate |
components/pages/history/historyShareUrl.ts:7 |
| C5 | Avatar builds the DiceBear fallback at module load |
components/ui/Avatar.tsx:5-6, :32 |
The cuts depend on each other. C2 to C4 alone save about 6 kB, because the sheet bodies hold the same modules. With C1, they matter.
C1 alone makes a pad slower. Today the editor stack is inside _app (through BottomSheet, C1), and the DocumentPage chunks load after _app (corrected 2026-11-13). With C1 alone, the stack would download only after _app runs. So C1 ships with a warm-up of the pad chunks (step 3), and the step 3 gate measures it.
Steps
Each step is one commit. Each records its before and after. Agent in the repo builds every step. The maintainer pushes each with a (build): front tip.
- C3 and C4. Move
formatVersionDateinto its own small file. Replace the TiptapisMacOSimport with a local check. - C2. Change
hooks/useProfileSync.tsandhooks/useNotificationPreferences.tsto import from their own files by relative path (api/users/getUserById.tsandapi/rpc/getNotificationPreferences.ts), not from the@apibarrel.tsconfig.jsonhas no@api/*alias. Also cut the chainHomePage.tsx->ui/Avatar.tsx->ui/dialogs/UserProfileDialog.tsx->api/users/fetchLinkMetadata.ts(2026-11-13), or the hyperlink extension stays in/. Confirm with the route table that the hyperlink extension leaves_app. The hyperlink package exports only., sonormalizeHrefhas no subpath import. - C1 and the warm-up, together.
- Load
BottomSheetwithnext/dynamicandssr: false. On non-document routes, start theBottomSheetimport after theloadevent. Schedule it withrequestIdleCallback(cb, { timeout: 2000 })where it exists, elsesetTimeout(cb, 1), asutils/ensureEmojiData.tsdoes. It still mounts closed before any open. Do not mount it on first open: a late history push hits the Safari back race of Chat icon in the phone TOC drawer does not open the chat on iPhone Safari #639. - Keep one sheet system, and keep it inside
AppQueryClientRoot. - A chunk failure while offline must show an error path, because
openSheetalone shows nothing. - In
pages/[...slugs].tsx, startimport()ofDocumentPageat module scope, so its chunks download while_appruns. - Record Home wire bytes (the Load only the 71 brand icons the social links use, so Home stops shipping three whole icon packs #732 method) beside the route table.
- A/A pair first. Two before sets run on one day. Each gate is "after median at most before median + max(stated bound, A/A median gap)". Quote "lower" only when the after median is below the before minimum.
- Pad gate. Local production build (
build:ci, thenstart:prod), one scratch pad, n = 10 cold runs per side. Pass: t1 and t2 medians at most before + 50 ms, and max not worse by more than 10 %. Production/demo, n = 10 per side, for the claim. Pass: t2 median at most before + 5 %. - Fallback, if the gate fails. Emit
<link rel="preload" as="script">for theDocumentPagechunk files, read from.next/react-loadable-manifest.json, in_document.tsxon pad routes only. Record the timeline for both variants.
- Load
- C5. Load the DiceBear fallback on idle, with the same
requestIdleCallbackandsetTimeoutfallback as step 3. Show a same-sizeskeleton rounded-fullbone until it is ready. - Sentry tracing code. Set
bundleSizeOptimizations: { excludeDebugStatements: true, excludeTracing: true }atapps/webapp/next.config.js:431(tracesSampleRateis 0). Record_appkB before and after. Verify: one local test error, with a dummy DSN onlocalhost:9, still carriescontexts.trace.trace_idin its envelope. Record whether a client navigation changestrace_id, before and after step 5. After step 5, one trace is one page load. So step 5 ships last, after the Patch y-indexeddb so a closed offline copy cannot stop pad updates, and WebKit can compact it #751 and Make GlitchTip browser counts usable: one Safari IndexedDB event per page load, no service-worker register noise #752 7-day reads. - CI bundle budget (from [Tracking] Make docs.plus pages load faster: web bundle and page speed #571). A Bun script after
build:cireads.next/build-manifest.json. For/and/[...slugs], it takes the union ofpages[route]andpages['/_app']. For_app, it takespages['/_app']alone. It keeps.jsfiles only, gzips each withBun.gzipSync, and sums the bytes. Neither route list holds the_appchunk, andpages['/_app']also lists a CSS file. Check once that each total is within 1 % of thebuild:ciroute table before setting limits. The script exits 1 above budget. Budget = this issue's after plus 5 %. Prove it with a red run from a deliberate oversize import. The maintainer approves the limits.
Out of scope:
- Hoisting the collab provider into the page. It needs a ruling and the step 3 numbers first.
- Toolbar re-renders. Measure them with React Profiler first.
- Dropping
mobile-detect. Client and server must agree on "mobile".
UX checks (each step)
Devices: iOS 27 Safari on an iPhone, current Android Chrome, desktop Chrome 157 and desktop Safari 27. The maintainer runs the phone checks.
- No new flash or blank frame on Home or the pad. Light and dark, 390 px and 1280 px.
- Step 3, on iOS Safari and Android Chrome:
- Sign-in opens on Home. On iOS Safari, it also opens right after load.
- The TOC drawer hands off to filters.
- A slash command keeps the keyboard up (scratch pad, never
/demo). - The gallery and the Documents row menu open inside their parent.
- Hardware Back closes one sheet at a time.
- An offline chunk failure shows the error path.
- On a scratch pad the agent creates on the local stack: go offline, reload, type
/at 390 px. The slash-menu sheet opens. Delete the pad after.
- Step 4: a signed-in Home with no photo shows the bone, then the face, with no shift.
- Step 5: an error still reaches GlitchTip, with
contexts.trace.trace_id.
Rollback
Each step is one commit. Revert it and push a (build): front tip.
Acceptance criteria
- The Home before and the route tables are in a
Measuredcomment before the first commit. The pad timeline before is in aMeasuredcomment before step 3. - Each step's route table is in its comment.
- The step 3 pad gate passes, locally and on production
/demo. - Every UX check passes.
- The step 6 budget job is red on a deliberate oversize import and green on
main. - The production after
Measuredcomment exists, with the same settings. - The v2.3.7 benchmark ledger: every quotable claim, with n, range, condition and source #796 Web speed row holds the after numbers and links the after
Measuredcomment.
Activity
HMarzban commentedon Nov 13, 2026
Maintainer ruling, 2026-11-13: moved to v2.3.7. C1 needs the pad gate. The gate needs
scripts/bench/pad-timeline.ts, which needsplaywright-core, and that ruling is due 2026-11-19. No pad before exists yet.Confounds to record before the Home before: #701 (editor stack) and
c9cd2c98a(extension-hyperlink autolink fix), which ships with the 2026-11-14 webapp roll. C2 must also cut the chainHomePage.tsx->ui/Avatar.tsx->ui/dialogs/UserProfileDialog.tsx->api/users/fetchLinkMetadata.ts, or the hyperlink extension stays in/.HMarzban commentedon Nov 13, 2026
Step 6 note from the 2026-11-13 production before (#763 Measured): the pad budget misses the editor chunks.
At
9f132692e,/demoHTML loads 8 scripts:polyfills,webpack,framework,main,_app,[...slugs]and the two manifests. It loads no editor chunk.DocumentPageisnext/dynamicwithssr: false(apps/webapp/src/pages/[...slugs].tsx:32), so its chunks start only after_appand the page chunk run. The[...slugs]chunk is 5,635 B on the wire.Two changes follow:
pages['/[...slugs]']pluspages['/_app']from.next/build-manifest.jsondoes not hold theDocumentPagechunks. For the pad route, also add theDocumentPageentry from.next/react-loadable-manifest.json(the file the step 3 fallback already reads). Keepbuild-manifest.jsonandreact-loadable-manifest.jsonin the CI artifact, so each budget run can be checked later._app" does not match production. Today the editor stack is inside_app(throughBottomSheet, C1), and theDocumentPagechunks load after_app. C1 alone still makes a pad slower: the stack would then download after_appruns. So the step 3 warm-up and gate stay as written.No action is needed on steps 1 to 5.
HMarzban commentedon Nov 16, 2026
Maintainer ruling, 2026-11-16
Answered by the maintainer in the 2026-11-16 working session; posted by the agent.
pad-timeline.tsinpackages/document-swarm, which already hasplaywright1.64.1. This is not the thread's recommended option (A, a root devDependency); B is the deliberate choice.HMarzban commentedon Nov 16, 2026
Review, 2026-11-16 (maintainer approved).
packages/document-swarm/src/pad-timeline.ts. The open A/B line is marked ruled._app, and C2 also cuts theHomePage.tsx->ui/Avatar.tsx->ui/dialogs/UserProfileDialog.tsx->api/users/fetchLinkMetadata.tschain.apps/webapp/next.config.js:431./demooffline check. The ledger pointer is now v2.3.7 benchmark ledger: every quotable claim, with n, range, condition and source #796.fillcheck.tsname waits for the Clear y-tiptap position-migration maps on the server, so big pads load faster #738 step 5 ruling.