scala-js/scala-js — pull request #320 by sjrd (2014-02-28 17:23:31+00:00)
Title: Type-aware dce

This is the brand new type-aware dead code elimination for Scala.js!

Thanks to the awesome work of @gzm0 on the `@JSExport` feature, it is now possible for an automated dce algorithm to decide which parts of the emitted .js files are actually used (or at least, remove *many* parts that can be proven unused). This PR implements such an algorithm.

Results are relatively impressive: `packageJS` for the Reversi emits roughly 22 MB of .js. After `preoptimizeJS` (the dce), only 2.2 MB remain (only 10 % !), in virtually no more time than `packageJS`. (making `preoptimizeJS` a viable alternative to `packageJS` for dev cycle, because browser refresh is then much faster).

Rewiring `optimizeJS` to use the output of `preoptimizeJS` instead of `packageJS` produce optimized code ~25 % smaller, and a *lot* faster. Typically `optimizeJS` itself runs in a few seconds now, for a full total (compile -> optimizeJS) of 10 seconds.