Skip to content

PERF: reduce JS bundle size and improve initial load speed#1

Open
itsdiptabiswas wants to merge 1 commit into
mainfrom
perf/optimize-bundle-and-loading
Open

PERF: reduce JS bundle size and improve initial load speed#1
itsdiptabiswas wants to merge 1 commit into
mainfrom
perf/optimize-bundle-and-loading

Conversation

@itsdiptabiswas

Copy link
Copy Markdown
Owner

Summary

  • Dynamic imports for heavy components: PreviewFiles, VideoPreview, ManageAccess, and LottiePlayer are now lazy-loaded via next/dynamic with ssr: false, removing hundreds of KB (including video.js ~500KB) from every route's initial bundle
  • ReactQueryDevtools excluded from production: Wrapped in process.env.NODE_ENV check and loaded via next/dynamic — saves ~70-100KB in production builds
  • Bootstrap JS trimmed to only used modules: Replaced require("bootstrap") (full bundle) with selective dynamic imports for only modal, dropdown, and collapse — the three Bootstrap JS components actually used in the app
  • Auth waterfall broken with Suspense: Extracted session + user data fetching into a UserProfileWrapper async server component wrapped in <Suspense>, so the app shell (TopBarLoader, providers) renders immediately without waiting for the auth/user data waterfall

Test plan

  • Verify modals still open/close correctly (Bootstrap modal JS)
  • Verify dropdowns work (Bootstrap dropdown JS)
  • Verify accordion expand/collapse works (Bootstrap collapse JS)
  • Verify file preview works for images, videos, and text files
  • Verify resource details panel opens with LottiePlayer animation
  • Verify manage access modal opens correctly
  • Verify ReactQueryDevtools panel appears in development but not in production
  • Verify login flow and post-login navigation is faster
  • Verify profile data loads correctly with the Suspense boundary

- Dynamic import heavy components (PreviewFiles, VideoPreview, ManageAccess, LottiePlayer) via next/dynamic to reduce per-route JS bundle
- Load ReactQueryDevtools only in development via dynamic import + env check
- Replace full Bootstrap JS require() with selective module imports (modal, dropdown, collapse only)
- Convert BootstrapMethods utility to async dynamic imports instead of synchronous require()
- Wrap auth/user data fetching in Suspense boundary so the app shell renders without blocking on session + getUserInfo waterfall

Made-with: Cursor
@vercel

vercel Bot commented Mar 16, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
drive-clone Error Error Mar 16, 2026 4:45pm

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.

1 participant