react-starter-kit icon indicating copy to clipboard operation
react-starter-kit copied to clipboard

Build gets pretty big

Open codeorelse opened this issue 11 years ago • 9 comments

Hi,

When I build the react-starter-kit without any adjustments, the client app.js is over 280KB. I think this is quite huge, especially when using it in a mobile app. What are your thoughts on this? What can we do to optimise it?

Cheers!

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

codeorelse avatar Nov 02 '15 07:11 codeorelse

React with add ons alone is 140Kb

ChrisCinelli avatar Nov 03 '15 08:11 ChrisCinelli

When we serve the JS gzipped, it's getting very acceptable :). But still I think 140KB on top of the 140KB (React+addons) is quite a lot..

codeorelse avatar Nov 03 '15 09:11 codeorelse

Any big eCommerce site on a mobile phone will be a minimum 250kb in .js files. That's not considering extra external scripts and the monolithic CSS files they force you to download. To me, this is a trade off. No one said isomorphic sites were slim, or any site using a framework of any kind. Anyway, that's my two-cents.

doug-orchard avatar Nov 12 '15 22:11 doug-orchard

To reduce this file size, you may want to use code splitting, making sure that only the code which is actually is going to be used on the page is loaded at the initial load.

koistya avatar Nov 13 '15 00:11 koistya

I just downloaded the boilerplate and did an npm run build. The main.js in build/public is 3.33 MB in file-size. For real? Or am I doing something wrong here?

mimimimichael avatar Feb 27 '16 13:02 mimimimichael

@alotov-agina The production build is a lot smaller.

$ npm run build -- --release

codeorelse avatar Feb 27 '16 14:02 codeorelse

Note that build includes CSS, you can make it even faster and less with:

  1. code-splitting (https://github.com/webpack/webpack/tree/master/examples/code-splitting)
  2. plugins transform-react-remove-prop-types transform-react-constant-elements transform-react-inline-elements (see https://github.com/kriasoft/react-starter-kit/pull/440)
  3. use NODE_ENV=production

Bogdaan avatar Feb 27 '16 15:02 Bogdaan

Thank you guys!

mimimimichael avatar Feb 27 '16 15:02 mimimimichael

@codeorelse thank you very much for crating this issue! Unfortunately, we have close it due to inactivity. Feel free to re-open it or join our Discord channel for discussion.

NOTE: The main branch has been updated with React Starter Kit v2, using JAM-style architecture.

ulani avatar May 27 '21 19:05 ulani