2mb is a LOT of code, like an absurd amount for most projects. That almost always points to larger issues, like a complete disregard for bundle size in the first place.
And if the project isn't worrying about bundle size at all, then even their vanilla/jquery page is going to end up bloating a ton as well.
More often than not the culprit in 2mb bundle sizes is a a few packages that include "data" in the bundle (For example, i've seen timezone and locale information bloat bundles by megabytes, and in one case a 5mb bundle ended up being 4.6mb of zip codes...)
lol I did it too once! We were making a PoC one time for a small app, and ended up needing a way to quickly determine some location information related to the zip. I remembered that I saw the ~5mb bundle once that had all the zipcodes in it, and found a library that would let me do that, and bundled it right in.
The PoC ended up working out, and we built the infra to correctly handle the lookups without needing to bundle the entire country from there, but man did that raise some eyebrows from a few other devs that noticed it!
Having used the internet for 25 years I can confidently say most React apps are far smaller than most jQuery apps, mainly because jQuery apps didn't use compilers or bundlers. Hell, most didn't even use minifiers.
Even ignoring that, React app sizes are getting better. Modern React apps (basically since 16.7) that are written with things like Suspense, lazy, and hooks are usually pretty small. Writing functional components and composing your app pushes you to write less code. Plus React gets things like code splitting for free with webpack if you use lazy, so the first page load only downloads things that are actually needed to get to interactive.
No doubt some less considerate developers will still manage to write giant apps that take ages to get started, but they don't have to. Bloated apps are a function of developer's choices rather than React (or any other JS framework) forcing the apps to be bloated.
> Modern React apps (basically since 16.7) that are written with things like Suspense, lazy, and hooks are usually pretty small.
Come on, 16.7 was released in December and 16.8, with stable Hooks, was last week! It's interesting that React has added these features and it bodes well for the future but you can't claim capabilities that have only existed for the a few months is what constitutes "modern." React's pace of adoption has been remarkable but that also means there's a lot of code that already exists that isn't going to be changed right away to take advantage of these features.
These features existed in the form of 3rd party libraries like react-loadable for code splitting and recompose for hooks. I don't know any serious React devs who haven't used code splitting in the past few years, and recompose was very popular as well. We just have a canonical way of doing these things now.
And if the project isn't worrying about bundle size at all, then even their vanilla/jquery page is going to end up bloating a ton as well.
More often than not the culprit in 2mb bundle sizes is a a few packages that include "data" in the bundle (For example, i've seen timezone and locale information bloat bundles by megabytes, and in one case a 5mb bundle ended up being 4.6mb of zip codes...)