digitalfabrik / integreat-app

React JS and React Native App for Integreat
https://integreat.app
MIT License
45 stars 15 forks source link

Reduce javascript execution time #2499

Open steffenkleinle opened 9 months ago

steffenkleinle commented 9 months ago

Is your feature request related to a problem? Please describe. Google still thinks our mobile performance is too slow, i.e. we have a LCP longer than 2.5 on most sites on mobile. Therefore we should try to speed up our web app more.

Describe the solution you'd like Investigate whether we can reduce javascript execution time: https://developer.chrome.com/docs/lighthouse/performance/bootup-time/?utm_source=lighthouse&utm_medium=lr#how-to-speed-up-javascript-execution

Describe alternatives you've considered None.

Additional context LCP: https://search.google.com/search-console/core-web-vitals/drilldown?resource_id=https%3A%2F%2Fintegreat.app%2F&item_key=CAMQAhgC

Part of #2371 , relates to #2498.

sarahsporck commented 7 months ago

Maybe check out https://web.dev/learn/performance

sarahsporck commented 4 months ago

This adresses bundle size and code compression:

It seams tree shaking does not work for lodash. The bundle still contains unused components. When switching to function imports this is fixed e.g. from import { isEqual } from 'lodash' to import isEqual from 'lodash'. Compare with the bundle analyzer. Sadly, i18next and luxon don't support tree-shaking.

We could also add "sideEffects": false to the translation, shared and build-configs project. This allows webpack to remove unused code from thes projects. https://webpack.js.org/configuration/optimization/#optimizationsideeffects

All over these changes could reduce the bundle size from around 791kb gzipped to 777kb gzipped.

steffenkleinle commented 4 months ago

Hmm, doesn't sound like a lot (< 2%) but I guess it still makes sense to do what we can. No other optimization potential here?

sarahsporck commented 4 months ago

Steps to get the same report:

  1. Download Chrome (to have access to lighthouse)
  2. Open the Chromedevtools on Integreat
  3. Run the dev server in production mode: yarn run webpack-dev-server-ts --env config_name=integreat-test-cms
  4. Run lighthouse to checkout the results

[!Warning] Page Speed Insights might use slightly different throttling, resulting in slightly different results

To reproduce the same results: 1.. Create a new hardwareprofile in the network tap using these settings:

Things that might have a performance impact:

ztefanie commented 4 months ago

@sarahsporck Thanks for documenting your results here. :+1:

For reducing the main thread work, we have a separate ticket here: https://github.com/digitalfabrik/integreat-app/issues/2498