News for hackers. Stuff that matters.
Re:10 Years of Scala.js by no_wizard on Sunday February 05, 2023 @11:14AM (#34666042)
How big is an application written in Scala.JS on average? My sense is this is a very heavy runtime
Re:10 Years of Scala.js by AlexITC on Sunday February 05, 2023 @05:35PM (#34670441)
> 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/

- [2]: https://template-demo.wiringbits.net

- [3]: https://raw.githubusercontent.com/wiringbits/scala-webapp-te...

- [4]: https://template-demo-admin.wiringbits.net (credentials being demo/wiringbits)

- [5]: https://github.com/wiringbits/scala-webapp-template/blob/mas...

- [6]: https://github.com/wiringbits/scala-js-games

- [7]: https://raw.githubusercontent.com/wiringbits/scala-js-games/...

Re:10 Years of Scala.js by no_wizard on Sunday February 05, 2023 @06:57PM (#34671274)
Does 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

Re:10 Years of Scala.js by AlexITC on Sunday February 05, 2023 @07:30PM (#34671586)
While 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...

Re:10 Years of Scala.js by sjrd on Monday February 06, 2023 @01:20AM (#34674011)
Yes, it does. This is what Dynamic Imports are for. See https://www.scala-js.org/doc/project/module.html#dynamic-imp...