4 ms·
> My sense is this is a very heavy runtime It all depends on what you consider to be heavy. Having worked with sjs for some years, sjs code size is usually ne
by AlexITC 4y ago
> My sense is this is a very heavy runtime
It all depends on what you consider to be heavy.
Having worked with sjs for some years, sjs code size is usually negligible if you compare it to the sizes from its dependencies. I commonly that the app weights ~1-3mb but gzip compression helps quite a lot, reducing the compresed version to ~200-500kb.
To get concrete examples, let's focus on this app [1] that has an admin portal (based on react-admin and scalajs-react) and a web portal (based on react, slinky, and, material-ui 3).
The web app [2] weights ~2.5Mb, ~550kb compressed [3] (yes, mui is heavy but this wouldn't be too different on the js version).
The admin app [4] weights ~2Mb, ~570kb compressed [5] (react-admin is heavy too).
To get another example, check this simple sjs games [6] that had no js dependencies but a single sjs dependency, bundle is ~630kb, ~100kb compressed [7].
It is worth mentioning that none of these app got any effort on reducing its bundle size (worth exploring some day). Given the strong-compiler and the lack of reflection, Scala.js can perform very nice optimizations to remove any code that isn't necessary to the app execution.
- [1]: https://github.com/wiringbits/scala-webapp-template/ https://github.com/wiringbits/scala-webapp-template/
- [2]: https://template-demo.wiringbits.net https://template-demo.wiringbits.net
- [3]: https://raw.githubusercontent.com/wiringbits/scala-webapp-template/master/docs/assets/images/sssppa-web-code-size.png https://raw.githubusercontent.com/wiringbits/scala-webapp-te...
- [4]: https://template-demo-admin.wiringbits.net https://template-demo-admin.wiringbits.net (credentials being demo/wiringbits)
- [5]: https://github.com/wiringbits/scala-webapp-template/blob/master/docs/assets/images/sssppa-admin-code-size.png https://github.com/wiringbits/scala-webapp-template/blob/mas...
- [6]: https://github.com/wiringbits/scala-js-games https://github.com/wiringbits/scala-js-games
- [7]: https://raw.githubusercontent.com/wiringbits/scala-js-games/master/docs/images/sjs-games-code-size.png https://raw.githubusercontent.com/wiringbits/scala-js-games/...
- no_wizard 4y agoDoes it do any smart lazy loading cans/or code splitting based on entry points into different functionality of the application? This is the kind of optimization you can get from compilers like this, esp. leveraging the closure compiler
- AlexITC 4y agoWhile module splitting was introduced by sjs 1.3.0 [1], the apps I have linked do not use it just yet (well, technically, the games page uses it but it is a single page loading everything, so, no real benefit from it). [1]: http://www.scala-js.org/news/2020/10/16/announcing-scalajs-1.3.0/ http://www.scala-js.org/news/2020/10/16/announcing-scalajs-1...
- sjrd 4y agoYes, it does. This is what Dynamic Imports are for. See https://www.scala-js.org/doc/project/module.html#dynamic-imports https://www.scala-js.org/doc/project/module.html#dynamic-imp...