How to Reduce react.js project Bundle size - reactjs

I have created a project whose build size is 26mb, then i removed useless packages, dead codes and much more useless stuffs from the project and it's code been reduced to 17mb but i want to reduce it further up to 10mb, idk which packages do i need here to compress the bundle size enter image description here

Add dependencies that you need only for development like react-testing-library, into devDependencies.
That should help.
Check for images and assets might help too

Related

Why is expo apk file very large even with just one screen code?

My expo apk file has a size of 45.8 MB.
Look at the apk size in the screenshot below.
App Info on Device
Expo apk size Vs android studio apk
How can I get a smaller APK-Size?
There are many way's to reduce the size of your distributed app.
I'm afraid you have to read & learn something about this, because this isn't a short & easy answer - at least, because there are many hooks where you can adjust your deployment-process to optimize your app(size).
But here some first suggestions:
If possible use React Native CLI to initialize your Project (instead of EXPO)
Don't use an existing React-Native Module for each stuff you do. Sometimes it gives you a lower footprint to code easy stuff by your own instead to import an npm-module from third-party
Keep your files (audio, video, images) bundled with your app as low as possible, think about to use SVG where possible.
Better use "app-bundle" for Android-Apps as general "apk-releases" (keyword: gradlew
bundleRelease vs gradlew assembleRelease)
Don't miss to read the Performance Section in React-Native Docs
build.gradle gives you additional Options to optimize your App for bundling-Process. Be sure that you use Proguard with shrinkRessources to minimize your apk / bundle (keywords: Proguard, seperateBuildPerCPUArchitecture)
PS: Best result you can gain, with lowest effort to spend (only for Android-Apps): Switch from APK to Bundle (AAP) see Docs

production build is too big

My src folder total size is 2.6 MB and the production build is 2.7 MB. It is taking too much time to load in the browser. I am generating a build using npm run build. I have started my project with create-react-app command. How to reduce the bundle size? Please help me.
I followed this link https://codeburst.io/how-i-cut-my-react-javascript-bundle-size-in-half-with-three-lines-of-code-fe7798ecbd3f as well but the result is same.
To increase loading performance of your app, another pointer could be using code splitting feature from webpack.
Or you can even consider Server-Side Rendering with react-based frameworks like nextjs or gatsby
You can increase your application perforce there are some methods to follow
We have to use React Js latest version or above 16
We have to Remove unwanted imports in the components
Using shouldComponentUpdate()we have to control the rendering method, if its necessary then only render the component
Re Usable of components
Using Lazy Loading Concept we can increase the performance

Webpack production build bundle is too huge

I am using React with Webpack for my project. My project is very very huge. It consists of 10-12 modules and bundling of one module related JS files is taking 460KB file size. I am worried that it may take up to 5MB bundle size after I wrote code for all the modules in my project.
How can I reduce the bundle size or any suggestions to bundle for large scalable project with React and Webpack.
Thanks in advance!
You could use tree shaking of your project after you finish it.
Take a look at the official webpack docs for this: https://webpack.js.org/guides/tree-shaking/
Things you can do to keep the bundle size at minimum.
Code splitting
Production configuration optimization e.g webpack --mode production
gZip compression
minify (uglify) code
This will reduce your bundle size drastically.

HTML in webpack bundle. Why?

Good day,
I'm building and angular 2 app based off of this starter pack. I'm trying to get a handle on what our build process will look like. I noticed when running:
npm run build:prod
npm run server:prod
That html is located within the bundle file.In large applications this bundle file could be upwards 4-5mb or more. This could be a problem for mobile access. And that seems counter intuitive to the angular 2 approach.
Is this correct build for a large applications?
Shouldn't the HTML files be loaded as needed rather than all at once?
Perhaps I have misunderstood something.
Yeah basically that's what Webpack does. It bundles everything. Having your output file ~4MB is very likely to happen. What you need is to separate the file into chunks. Using the common chunk plugin this way you'll be able to bring let's say all your third-party libraries into one chunk.
Secondly, you can break the file further into more chunks then load them asynchronously.
you can find more about this in the link.

webpack, why react-dom increase size in about 150kb?

we are working in a webpack, react, redux, ... based project. Trying to minimize as much as possible the final bundled file we found that react-dom increases the file size in about 150kb.
We have made some tests creating a dummy app that only includes react and the final minimized+optimized size is about 20kb (something reasonable taking into account the minimized version of react.
Next if we also include react-dom the final bundled size is about 170kb.
Is really react-dom as big? Anybody has some experiences to share.
Thanks in advance.

Resources