Skip to content

feat(perf): implement lazy loading and code splitting for faster star…#480

Open
sweetesty wants to merge 1 commit into
Smartdevs17:mainfrom
sweetesty:feat/410-lazy-loading-code-splitting
Open

feat(perf): implement lazy loading and code splitting for faster star…#480
sweetesty wants to merge 1 commit into
Smartdevs17:mainfrom
sweetesty:feat/410-lazy-loading-code-splitting

Conversation

@sweetesty
Copy link
Copy Markdown

Closes #410


This PR implements lazy loading and code splitting across the app to reduce cold start time and bundle size.

What was done:

metro.config.js

  • Metro code splitting configured to enable async bundle loading
  • Chunking strategy defined: critical auth/home screens in the main bundle; secondary screens (settings, reports, details) in async chunks

src/navigation/AppNavigator.tsx

  • Non-critical screens converted to React.lazy() imports
  • Suspense boundaries added around lazy-loaded screen groups with lightweight fallback components
  • Frequently used screens (e.g. home, dashboard) kept as eager imports to avoid perceptible loading delays on primary flows
  • Bundle loading failures caught at the Suspense boundary level with an error fallback UI and retry option, preventing a blank screen on chunk load failure

src/screens/

  • Secondary and infrequently accessed screens refactored for dynamic import compatibility
  • No changes to screen component logic — only import strategy updated

Prefetching

  • Critical secondary modules prefetched during app idle time using InteractionManager.runAfterInteractions so they are warm before the user navigates to them

Bundle size analysis

  • Full bundle analysis report generated and included at docs/bundle-analysis.md
  • Main bundle size reduction documented; per-chunk sizes listed

Performance CI check

  • Performance regression check added to CI pipeline — build fails if main bundle size exceeds the defined threshold
  • Cold start time measured and documented against the <2s target

Acceptance criteria met:

  • ✅ Metro code splitting configuration
  • ✅ Lazy-loaded screens with Suspense boundaries
  • ✅ Bundle loading failure handling
  • ✅ Eager vs lazy tradeoff applied — critical screens kept eager
  • ✅ Prefetching critical modules on app idle
  • ✅ Bundle size analysis report
  • ✅ Performance regression CI check
  • ✅ Startup time reduction targeting <2s cold start

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@sweetesty Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Reduce app startup time with lazy loading and code splitting

1 participant