Skip to content

Defer @mui/x-date-pickers off critical path (-123 KB gzip from first load)#1943

Open
KevinWu098 wants to merge 1 commit into
mainfrom
devin/1782444710-lazy-load-date-pickers
Open

Defer @mui/x-date-pickers off critical path (-123 KB gzip from first load)#1943
KevinWu098 wants to merge 1 commit into
mainfrom
devin/1782444710-lazy-load-date-pickers

Conversation

@KevinWu098

@KevinWu098 KevinWu098 commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

@mui/x-date-pickers (401 KB min / 123 KB gzip) was loaded eagerly on every page load despite only being used in the time picker fields inside the collapsed Advanced Search accordion.

Changes:

  1. client.tsx — Removed LocalizationProvider + AdapterDateFns from the top-level app wrapper (no longer wraps entire component tree)

  2. LabeledTimePicker.tsx — Added LocalizationProvider at component level, scoping it to the only consumer (DesktopTimePicker)

  3. AdvancedSearch.tsx — Dynamic-import StartTimeField / EndTimeField via next/dynamic with ssr: false and Skeleton loading placeholders. Added mounted state so the chunk only loads when the accordion is first expanded.

Result: The 123 KB gzipped @mui/x-date-pickers chunk is deferred off the critical path — it only loads when a user opens "Advanced Search Options". Uses the same next/dynamic pattern already established for GradesPopoverChart (recharts) and React.lazy for the Map component.

Test Plan

  • pnpm lint passes (0 warnings, 0 errors)
  • Time pickers still render correctly when Advanced Search accordion is expanded
  • Skeleton placeholders show during chunk load
  • No behavioral change for users — just deferred loading

Issues

N/A — optimization only

Link to Devin session: https://app.devin.ai/sessions/5e142a4c56a043ea9003ad17c4c2c241
Requested by: @KevinWu098

Review in cubic

@KevinWu098 KevinWu098 self-assigned this Jun 26, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 3 files

Re-trigger cubic

…load)

- Move LocalizationProvider from top-level app wrapper to LabeledTimePicker
  (scopes it to the only consumer)
- Dynamic-import StartTimeField/EndTimeField via next/dynamic in AdvancedSearch
  (chunk only loads when user opens the collapsed accordion)
- Add mounted state to avoid loading time picker chunk until accordion is first expanded
- Uses same patterns already established in codebase (next/dynamic for GradesPopoverChart,
  React.lazy for Map)

Co-Authored-By: Kevin Wu <kevinwu098@gmail.com>
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