Reliqio.AI · production
Why code splitting split nothing
The app made the browser download 3,232 kB of JavaScript before it could even start. Code splitting was set up, and somehow it split nothing.
−57% entry bundle, from 3,232 to 1,390 kB
The Mapbox GL map engine alone weighed more than the rest of the app. Production made it worse: that 3 MB chunk went out uncompressed with max-age=0, so the browser fetched it again on every visit.
I measured what carried the weight before changing anything. Mapbox GL and the file-upload widget went behind React.lazy and dynamic import(), since most screens never need them. That alone wouldn't have helped. The real blocker was an import cycle between the UI and icon barrel files, and while it was there, the bundler couldn't split the code at all.
There was a sneaky part too. A single IDE auto-import could quietly pull the map back into the entry bundle, so the design system exports only the lazy wrapper, and the real component got a new name and a warning comment. The map is prefetched while the browser is idle (requestIdleCallback, with a setTimeout fallback for Safari), so screens with the map still open quickly. A failed prefetch is caught and stays quiet.
On the Node server I added compression, a one-year immutable cache for hashed files and no-cache for index.html, so a deploy reaches users right away. Before the app can start, the browser now downloads 446 kB of JavaScript instead of 3,232 kB, 86% less over the wire. The map still loads; it's just off the critical path now.
- React.lazy
- code splitting
- Mapbox GL
- HTTP caching
- gzip
- raw
- before3,232 kBafter1,390 kB
- gzip
- before962 kBafter446 kB
On Lighthouse's mobile connection of 1.6 Mbit/s the gzipped entry bundle arrives in 2.2 s instead of 4.8 s. Parsing and running the JavaScript come on top.
2.2× faster
- Before 4.8 s · 962 kB gzipped
- After 2.2 s · 446 kB gzipped
At the 1.6 Mbit/s of the Lighthouse mobile test. This is the download alone; parsing and running the JavaScript come on top.
// The design system exports this
// wrapper, not the heavy library
const MapViewImpl = lazy(
() => import("./map-view.impl"),
);
export function MapView(
props: MapViewProps,
) {
return (
<Suspense fallback={null}>
<MapViewImpl {...props} />
</Suspense>
);
}
// Warm the chunk up while idle;
// a failed prefetch is fine
const prefetch = () =>
import("./map-view.impl")
.catch(() => {});
if ("requestIdleCallback" in window) {
requestIdleCallback(prefetch);
} else {
setTimeout(prefetch, 1000);
}Fuel dispatch at Reliqio.AI
Booking, dispatch, customs clearance and ordering all had to work in one web app. I took it from an empty repository to production in under three months. Today 5+ logistics companies use it.
I split the frontend into 16 feature modules and built a shared design system with 165 components. A circular import was pulling UI and icon code into the entry bundle. I broke that import, moved Mapbox GL and file uploads into lazy chunks, prefetched them during browser idle time and added gzip and immutable caching in Express. The entry bundle fell from 3,232 to 1,390 kB. First-load JavaScript over the wire fell from 3,232 to 446 kB.
Stack: React 19, TypeScript, Vite, Radix UI, Mapbox GL, Express, Vitest, Playwright.