Elm is fast.
Can we make it faster?
Turns out, yes!
We’ve put together
elm-optimize-level-2 instead of
This speedup should essentially be “free” in that you don’t need to do anything to your code, and your post-minification asset sizes should actually be ever so slightly smaller than before.
Big Note - We’ve tested the code on all of our benchmarks and I’ve verified that things seem to be working as expected on Blissfully (our app is something like ~160k lines-of-code Elm program).
But also let us know how it goes!
Science and Speed
There are two sides to this project.
The first is that this is actually a science project to gather data on what JS forms would be beneficial for Elm. It’s a lab where we can try things, collect notes, and verify ideas with actual numbers.
The repo already includes:
- Documentation on interesting transformations
A browser-automated benchmarking suite, which allows us to run
elm-explorations/benchmarkbenchmarks from a number of realworld Elm projects and collect cross-browser numbers.
The second part of this project is to take the transformations that are the most useful and provide them as a tool you can use now.
Even though this is under my name on the repo, this has been a joint project with Simon Korzunov! I’m positive this project wouldn’t be nearly as comprehensive without him.
Also, my personal inspiration came from Robin Heggelund Hansen’s article on areas where the Elm Compiler’s output could be improved. Definitely check it out!
What sort of speedup are we talking about?
Well, first, there needs to be a bit of a disclaimer.
Your numbers will likely vary depending on a lot of different factors.
You may not see any speedup at all depending on what you’re doing.
However, we do have some very encouraging/exciting results!
Here’s a small sample:
|create a 4 level nested html tree||safari||34,899|
|create a 4 level nested html tree||final||safari||39,631||(+14%)|
|create a 4 level nested html tree||firefox||15,909|
|create a 4 level nested html tree||final||firefox||22,361||(+41%)|
|create a 4 level nested html tree||chrome||28,959|
|create a 4 level nested html tree||final||chrome||72,753||(+151%)|
Let us know if you try this out!
Happy to answer any questions. Hopefully everything works as intended and I’m not forgetting something
(Small note, the npm package was published incorrectly, but it now should be working.)