TheThingsNetwork / lorawan-stack

The Things Stack, an Open Source LoRaWAN Network Server
https://www.thethingsindustries.com/stack/
Apache License 2.0
993 stars 309 forks source link

Frontend assets are too big #359

Open htdvisser opened 5 years ago

htdvisser commented 5 years ago

Summary:

While working on Gzip (#350) I noticed that our static assets are very big.

Steps to Reproduce:

  1. Just look in the public dir.

What do you see now?

Several MBs that users need to download when opening the OAuth page or Console.

What do you want to see instead?

Less

How do you propose to implement this?

What can you do yourself and what do you need help with?

I can submit a PR with optimized images, the rest is up to @kschiffer and @bafonins.

kschiffer commented 5 years ago

As far as the OAuth bundle goes, I can see that there are some dependencies attached that the OAuth app is not actually using (eg. react-select, clipboard.js). We should try looking into optimizations like tree-shaking to make sure we don't have dead code in the bundles. Especially the OAuth app should be really slim, as there is really not much happening in there.

kschiffer commented 5 years ago

After putting the webpack stats.json into webpack visualizer, I can see that in the OAuth bundle, a lot of space is consumed e.g. by formik and rxjs which is a dependency of redux-logic. To really reduce bundle size, we need to try and avoid big bundles which we only use marginally.

bafonins commented 5 years ago

The issue is with the size of the react-ace dependency. We plan do code split the payload formats/events pages to reduce the bundle size.

htdvisser commented 5 years ago

Looks like we're not the only ones that dislike the size of the Ace editor. Have you considered using a smaller one like https://github.com/satya164/react-simple-code-editor instead?

bafonins commented 5 years ago

Indeed, we can try using react-simple-code-editor.

bafonins commented 4 years ago

Remark for later:

We can make use of browserslist that is used internally by babel. This can reduce the bundle by removing specific polyfills for browsers we do not support. Additionally, we can define separate instances for the development and production modes to speed up the webui build.