Skip to content
This repository was archived by the owner on Sep 15, 2026. It is now read-only.
This repository was archived by the owner on Sep 15, 2026. It is now read-only.

Split vendor bundles and subset fonts to cut carpincho-wallet popup load cost #30

Open
0 of 6 issues completed

Description

@gabitoesmiapodo

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 manualChunks carving stable vendor-react / vendor-radix chunks out of the eager entry.
  • Pinning @walletconnect/* and @zxcvbn-ts/* into named chunks plus a bundle-size budget guarding app-*.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. Add manualChunks for stable vendor-react and vendor-radix so the vendor hash stays cache-warm across app edits.
  • Finding 2 — High (vite.config.ts:22, src/wc/client.ts:69): absence of manualChunks makes the WC/zxcvbn split fragile — it depends on getSignClient keeping new Core() / SignClient.init() in an async closure. Pin @walletconnect/* and @zxcvbn-ts/* into named chunks and add a bundle-size budget on app-*.js.
  • Finding 3 — Medium (src/main.tsx:1): default @fontsource-variable/{manrope,jetbrains-mono} imports ship cyrillic, cyrillic-ext, greek, vietnamese woff2 (~80 KB .crx weight; unicode-range gated so not render-blocking). Import Latin-only entrypoints. (font-display: swap already 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 on document.visibilitychange/hidden or back off; hook already supports pollMs: null.
  • Finding 6 — Low (src/views/onboarding/useBorderTrace.tsx:112): continuous rAF loop during onboarding never stops re-scheduling while idle (guards redundant writes, respects prefers-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.

Acceptance criteria

  • vite.config.ts defines manualChunks splitting react/react-dom into vendor-react and Radix into vendor-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-*.js chunk 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

  1. added
    epicLarge body of work decomposed into smaller issues
    and removed
    enhancementNew feature or request
    on Jun 4, 2026
  2. changed the title [-]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[/+] on Jun 4, 2026
  3. removed
    epicLarge body of work decomposed into smaller issues
    on Jun 4, 2026
  4. changed the title [-]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[/+] on Jun 4, 2026
  5. added
    enhancementNew feature or request
    epicLarge body of work decomposed into smaller issues
    and removed
    enhancementNew feature or request
    on Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    epicLarge body of work decomposed into smaller issuespriority: mediumShould be addressed soon

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions