Skip to content

fix(performance): lazy loading, dns-prefetch, and chunk splitting#422

Open
gabitoesmiapodo wants to merge 2 commits intofix/a11yfrom
fix/performance
Open

fix(performance): lazy loading, dns-prefetch, and chunk splitting#422
gabitoesmiapodo wants to merge 2 commits intofix/a11yfrom
fix/performance

Conversation

@gabitoesmiapodo
Copy link
Collaborator

Summary

  • Add loading="lazy" to <img> in TokenLogo and Avatar
  • Add dns-prefetch hints for common blockchain RPC endpoints
  • Add manualChunks to split react, wagmi/viem, tanstack, chakra, and web3 into separate cached chunks

Test plan

  • pnpm test passes
  • pnpm build succeeds with separate vendor chunks visible in output

Copilot AI review requested due to automatic review settings March 23, 2026 21:45
@vercel
Copy link

vercel bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
components.dappbooster Ready Ready Preview, Comment Mar 24, 2026 0:05am
demo.dappbooster Ready Ready Preview Mar 24, 2026 0:05am
docs.dappbooster Ready Ready Preview, Comment Mar 24, 2026 0:05am

Request Review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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" to TokenLogo and Avatar <img> elements.
  • Add dns-prefetch hints for several blockchain RPC domains in index.html.
  • Configure Rollup manualChunks to 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'],
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
'vendor-react': ['react', 'react-dom'],
'vendor-react': ['react', 'react-dom', 'react-dom/client'],

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: react-dom/client added to the vendor-react chunk in the previous round of feedback.

Comment on lines +34 to +37
<!-- 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" />
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
<!-- 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" />

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

- 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.
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