Scope
File: src/app/layout.tsx
Problem
The initial JavaScript bundle includes all spatial rendering, tariff editing, and analytics libraries regardless of whether the user is a field engineer (needs only spatial + provisioning) or an administrator (needs tariffs + analytics). On slow field networks (2G/3G), this 500KB+ initial payload causes 10+ second load times.
Requirements
- Implement dynamic imports for heavy components:
GridMap → next/dynamic with ssr: false
LiveDataView → next/dynamic
TariffEditor → next/dynamic
TxModal → next/dynamic
- Each dynamic import should have a loading skeleton matching the component dimensions.
- Strip
@stellar/stellar-sdk, bignumber.js, and canvas libraries from the initial critical path.
- Use
React.lazy + Suspense as fallback for client-only transitions.
- Measure bundle size impact: target <150KB initial JS for field-focused routes.
Resolution Strategy
next/dynamic with named exports: dynamic(() => import("@/components/spatial/GridMap"), { ssr: false }).
- Loading skeleton: same border-radius, height, and background as the actual component.
- Verify with
npx next build and check the .next/static/chunks sizes.
Tags
layout, performance, code-splitting, network
Scope
File:
src/app/layout.tsxProblem
The initial JavaScript bundle includes all spatial rendering, tariff editing, and analytics libraries regardless of whether the user is a field engineer (needs only spatial + provisioning) or an administrator (needs tariffs + analytics). On slow field networks (2G/3G), this 500KB+ initial payload causes 10+ second load times.
Requirements
GridMap→next/dynamicwithssr: falseLiveDataView→next/dynamicTariffEditor→next/dynamicTxModal→next/dynamic@stellar/stellar-sdk,bignumber.js, and canvas libraries from the initial critical path.React.lazy+Suspenseas fallback for client-only transitions.Resolution Strategy
next/dynamicwith named exports:dynamic(() => import("@/components/spatial/GridMap"), { ssr: false }).npx next buildand check the.next/static/chunkssizes.Tags
layout, performance, code-splitting, network