How I Made Vite's First Paint 10x Slower by Trying to Optimize It
This is a concrete, data-backed reminder that frontend build tool defaults are battle-tested across thousands of projects. For Western developers who reflexively tweak Webpack or Vite configs, it's a sharp case study in how well-intentioned optimizations can crater performance — and why measurement should always come before manipulation.
A Vue3 + Vite project loaded in under a second out of the box. The developer, thinking they could improve caching and structure, added a manualChunks config that merged multiple third-party libraries into a single 2MB vendor file. That file took 6.5 seconds just to download, blocking all other resources and ballooning total load time to 7.5 seconds.
The post breaks down exactly why the optimization backfired: browsers don't handle monolithic JS files well (they block the main thread during parse/compile/execute), the merged vendor destroyed cache granularity (any single dependency update invalidates the whole 2MB chunk), and Vite's built-in splitVendorChunkPlugin already handles per-package splitting optimally for most projects.
The real lesson is a process one: never optimize without data. The developer recommends running Lighthouse first, measuring LCP, and only touching chunk config when there's a proven bottleneck — like a massive library that isn't needed on first screen, or multiple entry points sharing heavy common code.
The developer's mistake is common: conflating 'structure' with 'performance.' A clean vendor folder in the build output doesn't mean faster loading.
The 10x regression shows that browser loading behavior (parallelism, main-thread blocking) often outweighs the theoretical benefits of cache grouping.
Vite's default strategy is essentially a 'don't make me think' approach that has been validated at scale — overriding it without evidence is a form of premature optimization.
The post implicitly argues that build tool defaults are not just starting points but often the result of extensive real-world tuning by the tool's maintainers.
The most valuable takeaway is meta: the developer learned to distrust their own intuition and to let data drive decisions, a lesson that applies far beyond Vite config.