Kotlin.js file size

Sure, we are working on it. There are several possitble solutions to reduce kotlin.js size:

  1. Write our own tool that removes unnecessary parts of JavaScript files produced by Kotlin compiler.
  2. File-to-file compilation, when each Kotlin source file compiles to single JavaScript file. Tools like WebPack should remove unnecessary JavaScript files.
  3. Generate code for Google Closure Compiler. It’s very specific way, since GCC in advanced mode imposes restrictions on the code, and not all JavaScript libraries follow these restrictions.
  4. Compile program as a whole. This allows to perform dataflow analysis during compilation and derive which code is ever used.

I think we need all four options implemented someday. However, the easiest way for now is (1). We have a prototype of such tool that is capable of reducing miminal Hello Word application down to ~60 kilobytes. Another approach that we can implement in the near future is (2), it’s important, since modern JavaScript ecosystem uses file-to-file compilation.

3 Likes