Skip to content

perf(map): preload map chunk at module level with tile CDN hints#15

Merged
ronload merged 1 commit into
mainfrom
perf/improve-map-bundle-loading-process
Apr 15, 2026
Merged

perf(map): preload map chunk at module level with tile CDN hints#15
ronload merged 1 commit into
mainfrom
perf/improve-map-bundle-loading-process

Conversation

@ronload

@ronload ronload commented Apr 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace next/dynamic + requestIdleCallback with module-level import() guarded
    by matchMedia, so the ~1 MB maplibre-gl chunk starts downloading during hydration
    instead of after idle callback + first render
  • Prefetch counties GeoJSON data in parallel with the chunk download
  • Add preconnect and dns-prefetch hints for basemaps.cartocdn.com and
    tiles.basemaps.cartocdn.com to eliminate DNS/TLS latency for tile loading
  • Mobile remains unaffected -- the matchMedia guard prevents unnecessary downloads

Result

Map load time (page load to tiles ready): ~2.5s → ~1s

Test plan

  • Desktop: map renders within ~1s of page load
  • Mobile: no map chunk downloaded (verify in Network tab)
  • Resize browser from mobile to desktop width: map loads correctly via fallback import
  • Light/dark theme switching still works on the map

…e hints

The previous approach waited for requestIdleCallback + next/dynamic render
before starting the ~1 MB maplibre-gl chunk download, creating a serial
waterfall that delayed map visibility by ~2.5s. Now the chunk downloads
during hydration via a module-level import() guarded by matchMedia, and
counties data is prefetched in parallel. Preconnect/dns-prefetch hints for
basemaps.cartocdn.com and tiles.basemaps.cartocdn.com eliminate DNS+TLS
latency for tile loading. Total map load time reduced from ~2.5s to ~1s.
@vercel

vercel Bot commented Apr 15, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
zipkit Ready Ready Preview, Comment Apr 15, 2026 7:14am

@ronload ronload merged commit 4770063 into main Apr 15, 2026
3 checks passed
@ronload ronload deleted the perf/improve-map-bundle-loading-process branch April 15, 2026 07:15
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