Reduce the size of the built client JS files
Hi,
!435 (merged) started to rework the build process and strip some useless content out of the built client files. We are now at around 860ko for the main chunk and 450kb extra for the charts. Looking at the output of webpack-bundle-analyzer
, it seems we can shrink it even more. This is low priority, so I am just opening an issue to track possible ideas and enhancements on this subject.
-
By being more aggressive on Moment imported locales, we could strip it further, down by 5kb or so. -
Getting rid of currency-formatter
(usingIntl
API or doing it server side), we get rid of a large JSON blob of about 20kb. -
Getting rid of jQuery
(currently used by Boostrap code only) makes 85kb go away. -
react-datepicker
is imported in its minified version and weighs 66kb. -
We include the whole lodash
library (for various reasons), maybe we could use something like https://github.com/lodash/lodash-webpack-plugin to prevent from importing everything. Should investigate further. -
semver
is used for basically two versions comparisons and weighs almost 10kb. -
whatwg-fetch
(Fetch
polyfill) could be lazy loaded so that only user missing the API get it, and that is 13kb. -
Remove server translations from the client, about 10kb. -
Moving from React
topreact
+preact-compat
is about 115kb of minified JS gone. Plus, we could make use of https://github.com/developit/proptypes/blob/master/src/disabled.js to further stripprop-types
from production builds. -
Removing PropTypes
in production builds should be doable easily and reduce size of built files. -
We could lazy-load rc-color-picker
since most users won't need it, that's a 25kb win. Actually, maybe we should make apolyfill
chunk with all these extra polyfills and lazy-load it. -
Same as above, babel-polyfill
is 80kb large.
Note: Sizes are given in minified version, before eventually applying gzip. Also note that many people will most likely serve their Kresus over HTTPS, and that a usual way (but definitely not the best) to mitigate CRIME/BREACH attacks is to disable gzip compression when using HTTPS. So gzip sizes might not be a good indicator here.
Edited by Phyks