Repository navigation
Split vendor bundles and subset fonts to cut carpincho-wallet popup load cost #30
Description
Objective
Cut the carpincho-wallet popup's load and idle-runtime cost by making the existing (accidental) code-splitting explicit, subsetting fonts to Latin-only, lazy-loading crypto, and pausing always-on main-thread work — without regressing the async isolation and cleanup properties already in place.
Rationale
This is a static performance audit for a Chrome MV3 popup loading from the local extension bundle, so server/TTFB/CDN criteria do not apply; findings were verified against the actual dist-extension build. The popup eagerly loads an unsplit 776 KB raw (~245 KB gz) app entry chunk dominated by React, Radix, and @noble, all parsed before first paint. There is no manualChunks config, so the good splitting that already exists (WalletConnect and @zxcvbn-ts dictionaries are async-only) is implicit and accidental — it can regress silently the moment a future top-level symbol reference pulls a 1.2 MB vendor blob into the eager chunk with no warning.
Correction to common assumptions: WalletConnect (@walletconnect/*) and the @zxcvbn-ts language dictionaries are already code-split into async chunks and are NOT loaded on popup open (WC/noble vendor chunk 1.2 MB raw, zxcvbn language chunk 454 KB raw, both behind dynamic import). They are not the eager-load problem.
Scope
In scope:
- Explicit
manualChunkscarving stablevendor-react/vendor-radixchunks out of the eager entry. - Pinning
@walletconnect/*and@zxcvbn-ts/*into named chunks plus a bundle-size budget guardingapp-*.js. - Latin-only font subsetting; lazy-loading @noble keypair crypto.
- Pausing idle/hidden main-thread work (status poll, onboarding rAF loop).
Out of scope:
- cn-dappbooster dApp web app performance (separate effort).
- Network / TTFB / CDN (N/A for local extension load).
- Functional changes to wallet behavior; the audited-good async isolation and cleanup must not regress.
Architecture & technical considerations
- Stack: React 18, Vite 6, Tailwind v4, Radix, @noble crypto. Target package: carpincho-wallet.
- Finding 1 — High (
vite.config.ts:20): eager app entry chunk 776 KB raw / ~245 KB gz, unsplit. AddmanualChunksfor stablevendor-reactandvendor-radixso the vendor hash stays cache-warm across app edits. - Finding 2 — High (
vite.config.ts:22,src/wc/client.ts:69): absence ofmanualChunksmakes the WC/zxcvbn split fragile — it depends ongetSignClientkeepingnew Core()/SignClient.init()in an async closure. Pin@walletconnect/*and@zxcvbn-ts/*into named chunks and add a bundle-size budget onapp-*.js. - Finding 3 — Medium (
src/main.tsx:1): default@fontsource-variable/{manrope,jetbrains-mono}imports ship cyrillic, cyrillic-ext, greek, vietnamese woff2 (~80 KB.crxweight; unicode-range gated so not render-blocking). Import Latin-only entrypoints. (font-display: swapalready set, no FOIT.) - Finding 4 — Medium (
src/vault/keypair.ts:1): @noble ed25519 + sha512 sit in the eager chunk, loaded on every popup open though only needed at account creation/signing. Lazy-load behind those flows. - Finding 5 — Low (
src/hooks/useWalletServiceStatus.ts:65): polls every 5 s with no visibility gating (cleared on unmount:68, no leak). Pause ondocument.visibilitychange/hidden or back off; hook already supportspollMs: null. - Finding 6 — Low (
src/views/onboarding/useBorderTrace.tsx:112): continuous rAF loop during onboarding never stops re-scheduling while idle (guards redundant writes, respectsprefers-reduced-motion, cancels on cleanup). Stop re-scheduling once the tint is permanently held.
Done well — retain, do not regress: WC SignClient lazy + memoized (src/wc/client.ts:69); zxcvbn dictionaries dynamically imported with ready-state listener and last-input memo (src/vault/passwordStrength.ts:11, :39); all listeners/timers/observers have cleanup (src/vault/VaultContext.tsx:430, :448); HomeView memoizes derived data (src/views/HomeView.tsx:103); only an SVG logo and extension-size icons ship as images.
Issue breakdown
Recommended order: bundle splitting and the regression guard first, then font/crypto trimming, then idle main-thread work.
- [High] Split vendor-react and vendor-radix into stable manualChunks #41 — Split vendor-react and vendor-radix into stable manualChunks
- [High] Pin WalletConnect/zxcvbn chunks and add a bundle-size budget gate #42 — Pin WalletConnect/zxcvbn chunks and add a bundle-size budget gate
- [Medium] Import Latin-only font subsets in carpincho-wallet #43 — Import Latin-only font subsets in carpincho-wallet
- [Medium] Lazy-load @noble keypair crypto behind account-creation/signing flows #44 — Lazy-load @noble keypair crypto behind account-creation/signing flows
- [Low] Visibility-gate the wallet-service-status poll #45 — Visibility-gate the wallet-service-status poll
- [Low] Stop the onboarding border-trace rAF loop once settled #46 — Stop the onboarding border-trace rAF loop once settled
Acceptance criteria
-
vite.config.tsdefinesmanualChunkssplitting react/react-dom intovendor-reactand Radix intovendor-radix, separate from app code. -
@walletconnect/*and@zxcvbn-ts/*are pinned into named chunks and cannot leak into the eager entry. - A bundle-size budget fails the build if the eager
app-*.jschunk regresses. - Fonts ship Latin-only; the four non-Latin subsets are dropped.
- @noble keypair crypto is no longer in the eager popup-open chunk.
- No unbounded poll or rAF runs while the popup is idle or hidden.
- No regression to audited-good properties (WC/zxcvbn async isolation, listener/timer cleanup, memoization).
Activity
[-]Split vendor bundles and subset fonts to cut carpincho-wallet popup load cost[/-][+]Optimize Core Web Vitals (LCP, INP, CLS) for the carpincho-wallet popup[/+][-]Optimize Core Web Vitals (LCP, INP, CLS) for the carpincho-wallet popup[/-][+]Split vendor bundles and subset fonts to cut carpincho-wallet popup load cost[/+]