How to Reduce the Number of Output Files in Remix Build to Improve First Load Performance? #10620
Unanswered
huangcong12
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Remix team and community,
I'm developing a Shopify embedded app using Remix (with Vite), and I'm facing a significant performance issue related to first-time load speed.
🧩 Problem Description
After building the app, the output includes around 20+ small JS files, even for relatively simple pages. These files are mostly from manually split components and utility libraries (not routes), and result in many parallel HTTP requests when the app is first loaded. This leads to a noticeable white screen on slower connections and a poor first impression for new users — which is particularly problematic in an embedded Shopify context.
Even with Cloudflare CDN, the number of requests during the initial load still causes a significant delay.
🔧 What I've Tried
manualChunks in Vite
Attempted to merge libraries into a single
vendor.js
file usingrollupOptions.output.manualChunks
, but it doesn’t seem to effectively reduce the number of output chunks for my internal modules and components.Terser
Helps reduce file size, but not file count.
Custom Vite plugin attempts
Tried rewriting dynamic imports and aggressively bundling specific chunks, but results were limited.
Considered rewriting the app as a SPA entry point
I explored the idea of bypassing the Remix routing system and rendering everything from a single entry point to reduce bundle fragmentation — but I couldn't get it to work due to the complexity and tight coupling with Remix's conventions.
⚙️ Build Config Example
❓My Questions
Thanks a lot for any insights or suggestions!
Beta Was this translation helpful? Give feedback.
All reactions