fix(performance): lazy loading, dns-prefetch, and chunk splitting#422
fix(performance): lazy loading, dns-prefetch, and chunk splitting#422gabitoesmiapodo wants to merge 2 commits intofix/a11yfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR focuses on front-end performance optimizations by reducing initial image/network work and improving long-term caching via more stable vendor chunking in the Vite build.
Changes:
- Add
loading="lazy"toTokenLogoandAvatar<img>elements. - Add
dns-prefetchhints for several blockchain RPC domains inindex.html. - Configure Rollup
manualChunksto split major dependency groups into separate vendor chunks.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
vite.config.ts |
Adds build.rollupOptions.output.manualChunks to create stable vendor chunks for key dependency groups. |
src/components/sharedComponents/TokenLogo.tsx |
Adds lazy-loading to token logo images to reduce upfront image fetches. |
src/components/sharedComponents/Avatar.tsx |
Adds lazy-loading to ENS avatar images to reduce upfront image fetches. |
index.html |
Adds dns-prefetch resource hints for RPC endpoints to reduce DNS latency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
vite.config.ts
Outdated
| rollupOptions: { | ||
| output: { | ||
| manualChunks: { | ||
| 'vendor-react': ['react', 'react-dom'], |
There was a problem hiding this comment.
manualChunks groups react and react-dom, but the app imports react-dom/client (see src/main.tsx). Rollup treats subpath imports as separate module IDs, so react-dom/client can end up in a separate chunk, undermining the goal of a single cached React vendor bundle. Consider adding react-dom/client (and optionally other React subpaths you import) to vendor-react.
| 'vendor-react': ['react', 'react-dom'], | |
| 'vendor-react': ['react', 'react-dom', 'react-dom/client'], |
There was a problem hiding this comment.
Fixed: react-dom/client added to the vendor-react chunk in the previous round of feedback.
| <!-- DNS prefetch for blockchain RPC endpoints --> | ||
| <link rel="dns-prefetch" href="https://eth.llamarpc.com" /> | ||
| <link rel="dns-prefetch" href="https://cloudflare-eth.com" /> | ||
| <link rel="dns-prefetch" href="https://gateway.tenderly.co" /> |
There was a problem hiding this comment.
These dns-prefetch hints are hard-coded to specific public RPC hosts, but the app’s actual RPC endpoints are configured via PUBLIC_RPC_* env vars (see src/lib/networks.config.ts). As-is, this may prefetch domains that aren’t used (unnecessary DNS leakage + wasted work) and may miss the domains that are used in a given deployment. Suggest either removing these hints or generating them from the configured RPC URLs during build/deploy (so they always match the active RPC hosts).
| <!-- DNS prefetch for blockchain RPC endpoints --> | |
| <link rel="dns-prefetch" href="https://eth.llamarpc.com" /> | |
| <link rel="dns-prefetch" href="https://cloudflare-eth.com" /> | |
| <link rel="dns-prefetch" href="https://gateway.tenderly.co" /> |
There was a problem hiding this comment.
Not removing. The fallback RPCs (llamarpc, cloudflare, etc.) are the wagmi default public providers — for any deployment that doesn't configure custom RPCs they are the actual endpoints used. The hints are best-effort and cause no harm when a custom RPC is configured.
1664165 to
bd51b27
Compare
b84e168 to
184f8ea
Compare
184f8ea to
13e024b
Compare
bd51b27 to
2332bcb
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
13e024b to
3b7b376
Compare
2332bcb to
b1e43d7
Compare
22c9e54 to
6a2f37e
Compare
- Add loading="lazy" to img in TokenLogo and Avatar - Add dns-prefetch for common blockchain RPC endpoints - Add manualChunks to split vendor libs into separate cached chunks
Rollup treats subpath imports as separate module IDs; without explicitly including react-dom/client the subpath resolves into a separate chunk, splitting the React vendor bundle and defeating cache stability.
b1e43d7 to
ba8c91b
Compare
Summary
loading="lazy"to<img>inTokenLogoandAvatardns-prefetchhints for common blockchain RPC endpointsmanualChunksto split react, wagmi/viem, tanstack, chakra, and web3 into separate cached chunksTest plan
pnpm testpassespnpm buildsucceeds with separate vendor chunks visible in output