Short answer: unlikely.
When designing a language, there are always trade-offs to make. In particular, cross-compiling a language across JavaScript and another target typically leads to a series of more-or-less conflicting goals. For example, producing "idiomatic, readable JavaScript" is often at odds with producing "highly optimized JavaScript".
In that space, the main design goals of Scala.js are, in decreasing order of importance:
- Interoperability with JavaScript: the ability to call and be called by JavaScript code/libraries.
- Compatibility with Scala/JVM: unless using inherently platform-specific APIs (e.g., threads), the same Scala code should compile with Scala/JVM and Scala.js, and behave in the same way.
- Run-time performance: the resulting code should be as fast as possible.
- Code size: the resulting code should be as small as possible.
While code size is definitely a concern, as you can see, it sits pretty low on the list of main design goals. This means that code size concerns will typically yield to other concerns on the list.
In particular, it is often at odds with the requirement of compatibility with Scala/JVM. Indeed, Scala has a pretty large standard library, notably collections, and many parts of that library inter-depend on each other. This means that as soon as you use, say, a Scala List
, your code needs a significant portion of the standard Scala collections library. This portion of the stdlib is what makes most non-trivial Scala.js programs weigh above 150 KB.
Since the above conditions (design goals + collections library inter-dependencies) are unlikely to change in the foreseeable future, it is equally unlikely that Scala.js will suddenly produce less code.
Strictly speaking, it is possible to write a Scala.js application producing only 10 KB or a bit more. But in order to do so, you must be very careful not to use any parts of the collections library, ever. You should use js.Array
s, js.FunctionN
s and js.Promise
s everywhere, instead of List
s, =>
functions and Future
s, for example. At this point, Scala.js stops being Scala, and hence you would be better off with another language (e.g., BuckleScript).