Skip to content

Perf/lazy load recharts - #281

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
BharadwajKanneveti:perf/lazy-load-recharts
Jun 21, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
BharadwajKanneveti:perf/lazy-load-recharts

Conversation

@BharadwajKanneveti

Copy link
Copy Markdown
Contributor

Summary

This PR optimizes dashboard route performance by lazy-loading Recharts-based visualizations instead of eagerly bundling them into the initial client-side JavaScript.

  • Replaced static chart imports with next/dynamic imports using ssr: false.
  • Added skeleton loading fallbacks for dynamically loaded chart components.
  • Extracted inline Recharts chart implementations into dedicated child components:
    • shopping/shopping_charts.tsx
    • citations/citations_charts.tsx
    • topics/[id]/topic_charts.tsx
  • Updated dashboard pages to dynamically load chart components instead of importing Recharts directly.
  • Updated pages consuming shared chart components (_charts.tsx and agent-chart.tsx) to load them through next/dynamic.
  • Removed direct Recharts imports from dashboard route pages where chart rendering was moved into dynamically loaded child components.

Related issue

Closes #220

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

@BharadwajKanneveti

Copy link
Copy Markdown
Contributor Author

Hi @gkhngyk I have made the changes required if you find any issue please let me know i will make the changes asap.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pulled the branch and ran the full suite locally — typecheck, lint (0 errors), format:check, and a production build all pass, and every dynamically-loaded chart keeps its Skeleton fallback. Clean split of Recharts out of the initial dashboard bundle. Thanks @BharadwajKanneveti! 🙌

Tiny non-blocking nit for next time: the repo mostly uses kebab-case for component files (e.g. agent-chart.tsx, _charts.tsx), so shopping_charts.tsx → shopping-charts.tsx would match convention — not worth holding the merge for.

@gkhngyk
gkhngyk merged commit 7084cd8 into ansvisor:main Jun 21, 2026
3 checks passed
@gkhngyk gkhngyk mentioned this pull request Jun 21, 2026
4 of 12 tasks
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.

perf(dashboard): lazy-load recharts via next/dynamic to trim dashboard route JS

2 participants