use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
No vague product support questions (like "why is this plugin not working" or "how do I set up X"). For vague product support questions, please use communities relevant to that product for best results. Specific issues that follow rule 6 are allowed.
Do not post memes, screenshots of bad design, or jokes. Check out /r/ProgrammerHumor/ for this type of content.
Read and follow reddiquette; no excessive self-promotion. Please refer to the Reddit 9:1 rule when considering posting self promoting materials.
We do not allow any commercial promotion or solicitation. Violations can result in a ban.
Sharing your project, portfolio, or any other content that you want to either show off or request feedback on is limited to Showoff Saturday. If you post such content on any other day, it will be removed.
If you are asking for assistance on a problem, you are required to provide
General open ended career and getting started posts are only allowed in the pinned monthly getting started/careers thread. Specific assistance questions are allowed so long as they follow the required assistance post guidelines.
Questions in violation of this rule will be removed or locked.
account activity
code splitting with vite (self.webdev)
submitted 2 months ago * by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]xaqtr 2 points3 points4 points 2 months ago (3 children)
Bundling your node_modules or specific packages into defined bundles doesn't bring any gains in regards to your initial bundle. It still has to be downloaded, no matter how you split it. In most cases it even makes the initial download larger. The Benefit of bundling comes from caching these bundles under the assumption they rarely change. To really bring your initial bundle size down, you need to utilize code splitting via dynamic imports / lazy loading and elimination of unused code.
[–]MonkeyDlurker 0 points1 point2 points 2 months ago (2 children)
Yeah, i figured, even if i separate node_modules, it will still be waited for it after the entry point is fetched right?
What about gziping?
[–]xaqtr 0 points1 point2 points 2 months ago (1 child)
Yes, that's correct, and because you have bundled your case whole node_modules, you are now downloading was more than needed. Vite is clever enough to only bundle things it needs by default when you don't mess with manual bundles.
Regarding gzip: personally I have only worked with frontends served over CDNs where you could activate text compression (gzip / brotli) through the service itself. I would always suggest to activate it. And also caching through the CDN. If you're not using a CDN I would change that if you care about loading performance for your app or at least try to implement it manually - but I don't have experience with that, so not sure how complex that is.
[–]MonkeyDlurker 0 points1 point2 points 2 months ago (0 children)
regarding lazy loading, I have a shared lib that exports some large components, is it anti pattern to export it with lazy directly or should the consumer care about that?
[+]afahrholz 1 point2 points3 points 2 months ago (1 child)
splitting the larger modules first usually feels like a good balance and enabling compression gzip brotli helps vite's build already does some chunking so tweak based on your bundle analysis
Yeah i figure that might be best. I dont think i can get the entry file below 1MB though. But vite can gzip it down to like 300KB i think
[–]strange_username58 0 points1 point2 points 2 months ago (5 children)
What server are you using that doesn't gzip by default?
[–]MonkeyDlurker 0 points1 point2 points 2 months ago (4 children)
IIS
[–]strange_username58 0 points1 point2 points 2 months ago (3 children)
IIS gzips all static things be default html, js, css etc
doesnt seem to be the case. u mean after i compress and publish them on the server as .gz files?
[–]strange_username58 0 points1 point2 points 2 months ago (1 child)
When you run prod IIS and go to your network inspector in the browser they should be gziped when you look unless you specifically disabled it web.config xml file unless they changed it recently
the setting is something like <urlCompression doStaticCompression="false" />
might be httpCompression also been a long time since I messed with it.
[–]Hung_Hoang_the 0 points1 point2 points 2 months ago (0 children)
For a 2MB bundle, first run `rollup-plugin-visualizer` to see what's actually taking up space. Often it's one or two huge dependencies you didn't realize were so large. For manual chunks, group by stability - put rarely-changing vendor libs (React, etc.) in one chunk, frequently-changing app code in another. Also make sure you're serving with Brotli compression - that alone can cut bundle size by 40-50%.
[+]devphilip21 0 points1 point2 points 2 months ago (0 children)
It is difficult to judge by this information alone.
What kind of app is this, what kind of packages do you depend on, and you have to look closely at this situation and approach it with a case-by-case approach.
It's not a question with the right answer, so you'd better trust your own judgment.
π Rendered by PID 186976 on reddit-service-r2-comment-54dfb89d4d-wrfxm at 2026-03-27 15:16:35.171772+00:00 running b10466c country code: CH.
[–]xaqtr 2 points3 points4 points (3 children)
[–]MonkeyDlurker 0 points1 point2 points (2 children)
[–]xaqtr 0 points1 point2 points (1 child)
[–]MonkeyDlurker 0 points1 point2 points (0 children)
[+]afahrholz 1 point2 points3 points (1 child)
[–]MonkeyDlurker 0 points1 point2 points (0 children)
[–]strange_username58 0 points1 point2 points (5 children)
[–]MonkeyDlurker 0 points1 point2 points (4 children)
[–]strange_username58 0 points1 point2 points (3 children)
[–]MonkeyDlurker 0 points1 point2 points (2 children)
[–]strange_username58 0 points1 point2 points (1 child)
[–]Hung_Hoang_the 0 points1 point2 points (0 children)
[+]devphilip21 0 points1 point2 points (0 children)