Elm 0.19 introduced a bunch of optimizations to improve compile times and to make assets small. See the announcement here. It is conceivable to be a bit fancier, but we need to collect some user data.
For example, we can do even better on asset size if we have some sort of “code splitting” mechanism. Instead of turning 50k lines of code into one 114kb file, we can cut it into smaller chunks to get faster page loads overall. But as you you dig into this idea, it reveals itself to be extremely complex. Do you cut along packages? Modules? Functions? How do you draw those lines? For fastest first load? For caching that makes all subsequent loads faster? Should it work different for HTTP1 and HTTP2 clients? Are there nice defaults that cover 99% of cases? My goal is to end up with a design like --optimize
that makes all this easy by default, but instead of designing purely on instinct, we will first gather information about the people running large Elm applications.
If you have 50k+ lines of Elm at your company, you can help by sharing some information on the elm-dev mailing list:
- Real-life measurements of Elm’s contribution to page load times
- Screenshots or descriptions of two or three different pages
- The exact output of the
summarize.sh
script that appears below
I know folks have theories on the design they want, but please leave that out. The goal is just to get experience reports and knowledgable contacts.
The main benefit of this information is that we now have a basis for more specific questions. Maybe we find patterns that help improve compile times. Maybe they show a certain design will be difficult for some uses. Maybe it is actually a font that is causing slow loads, not Elm. Maybe there is no particular action to take at this time.
As always, we do not rush the design or implementation of language changes. Language changes are extremely costly. Packages need updateds, editor plugins need updates, applications need updates, etc. That means tens of thousands of people spending weeks of work. So I will prioritize based on what I think makes sense for the ecosystem overall, even if it is not the exact preference of specific individuals.
As a result of these constraints, there is no specific timeline for supporting code splitting. Finding a thoughtful and deliberate solution will be prioritized over finding stopgap measures. These designs can take a long time, tying together different problems in unpredictable ways, so it is likely that other projects will happen before this.
In the meantime, if you are running into measurable page load problems when compiling 100k or 200k lines into one file, I recommend creating a couple of independent files. Maybe your server can send different JS for /profile/*
, /settings/*
, and /*
. This will create some unsightly seams in your application, but it will also get sizes down. Perhaps you can preload things with service workers to smooth this out a bit. I think this should work for most cases, especially considering that the asset sizes are already exceptionally small. I also recommend optimizing things like font loading and CSS to see how far you can go with that. If you do not think that will work for your company, I recommend against using Elm right now.
If you have thoughts on this, please share them on https://discourse.elm-lang.org/ instead.
No one gets notified about any of the comments here, so it is like hiding a message in a tree in the woods. Someone may see it someday, but there are better ways to communicate.