Skip to content

Lazy-load the Recharts health-metrics charts to cut the commitment detail bundle #656

Description

@1nonlypiece

📌 Description

The four Recharts-based charts under src/components/dashboard/ (Value,
Drawdown, Fee, Compliance) are imported eagerly by
CommitmentHealthMetrics.tsx, pulling Recharts into the initial commitment-detail
bundle even though only the active tab is visible. This inflates the detail page's
JavaScript payload.

This issue lazy-loads the chart tabs with next/dynamic and a skeleton fallback
so Recharts loads only when a chart tab is actually viewed.

🎯 Requirements and Context

  • Dynamically import each chart tab; show HealthMetricsSkeleton while loading.
  • Default tab still renders correctly; switching tabs loads on demand.
  • No SSR mismatch; charts remain client-only as needed.
  • Measure and document the bundle reduction.

🛠️ Suggested Execution

1. Fork the repo and create a branch

git checkout -b perf/lazy-load-health-charts

2. Implement changes

  • Update src/components/dashboard/CommitmentHealthMetrics.tsx to use
    next/dynamic for each chart, with HealthMetricsSkeleton fallback.
  • Add src/components/dashboard/CommitmentHealthMetrics.lazy.test.tsx asserting
    the skeleton shows before a chart resolves and the right chart loads per tab.
  • Add docs/performance/LAZY_HEALTH_CHARTS.md with before/after bundle notes.
  • Validate no hydration warnings.

3. Test and commit

  • Run pnpm test.
  • Cover edge cases: switching tabs before load completes, default tab, repeated
    switching (no double-load).

Example commit message

perf: lazy-load health-metrics Recharts tabs on commitment detail

✅ Guidelines

  • Minimum 95% test coverage on new/changed lines.
  • Clear, reviewer-friendly documentation.
  • Timeframe: 96 hours.

🏷️ Labels

type-performance · area-frontend · MAYBE REWARDED · GRANTFOX OSS ·
OFFICIAL CAMPAIGN

💬 Community & Support

  • Join the CommitLabs contributor Discord to coordinate and get unblocked fast:
    https://discord.gg/WV7tdYkJk
  • Introduce yourself before starting so we can avoid duplicate work and pair you
    with a reviewer. Maintainers triage actively and review fast.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions