Skip to content

perf: lazy-load UI, chain connectors, and WalletConnect - 97% initial bundle reduction#7

Merged
azbang merged 5 commits into
hot-dao:mainfrom
ttarinov:perf/bundle-lazy-loading
Feb 20, 2026
Merged

perf: lazy-load UI, chain connectors, and WalletConnect - 97% initial bundle reduction#7
azbang merged 5 commits into
hot-dao:mainfrom
ttarinov:perf/bundle-lazy-loading

Conversation

@ttarinov
Copy link
Copy Markdown
Contributor

I was having a problem with integration kit to the static react project and needed to implement the lazy loadings, chunk retry logic, etc.

refs:
I've been checking some references, and wagmi have dynamic SDK imports in getProvider()), RainbowKit (sideEffects: ["reset.css.ts"], and @solana/wallet-adapter using sideEffects: false + dynamic Ledger SDK import at connect() time.

List of improuvements:

  • Lazy-load the entire UI router (lottie, styled-components, qr-code-styling, all React components) via dynamic imports - loaded only when user interaction happens
  • Convert default chain connectors to dynamic imports - each chain SDK loads only when its connector initializes
  • Lazy-load @walletconnect/universal-provider inside initWalletConnect() instead of static top-level import
  • Defer token polling and API calls until first wallet actually connects
  • Add sideEffects field to package.json enabling bundler tree-shaking

Results (measured with esbuild code-splitting)
Initial entry chunk - 1,154 KB >> 34 KB
UI/Router - in entry >> 1,004 KB deferred chunk (loads on user interaction)
Chain SDKs - in entry >> separate chunks (load on connector init)
WalletConnect - in entry >> deferred (loads on WC init)
Token API calls - immediate on new HotKit() >> on first wallet connect

Tests:
tsc, verified sideEffects paths match the build output, tested wallet connect flow (connectors load on demand), tested bridge/withdraw/deposit UI (router loads on first open), tested token list appears after wallet connects (deferred polling), checked briefly that WalletConnect QR flow still works

@ttarinov ttarinov force-pushed the perf/bundle-lazy-loading branch from 7d9981e to 496fe9d Compare February 19, 2026 02:15
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.

2 participants