penguin-academy / covid-19-py

COVID-19 Web App for Paraguay
https://autoreporte.org
Other
50 stars 18 forks source link

Reduce bundle size #143

Closed voluntadpear closed 4 years ago

voluntadpear commented 4 years ago

This PR adds some code splitting to reduce the amount of JS downloaded during the first visit. This way, d3 related assets will be loaded only when visiting /stats, lottie only during /success, etc.

Furthermore, the specific lodash.debounce is used to avoid including extra utilities not used from the lodash bundle.

npm run analyze is added to gather bundle statistics from the production build.

Before:

image

The main big chunk of code loaded was 2.20c3217b.chunk.js (1.5 MB ~ 400 kb gzipped)

After:

image

The chunk loaded during the home visit is 3.d02e32a0.chunk.js (273.14 KB) and additional chunks exist for all of our main routes containing their respective dependencies.

pA1nD commented 4 years ago

awesome!!