In Elm 0.18 and previous versions, the Elm core is included in each kit.
This can be inefficient, for example, if you download various Elm components to multiple pages. Each page will require its own package, but the Elm core will be included in each set.
Workaround (untested!)
- Compile your Elm code into a package,
output.js Open output.js and from the beginning of the file to the last var declaration, which looks something like this:
var _elm_lang$html$Html_Events$Options = F2(
Below this last variable declaration, starting with _elm_lang , you should see the code for the module you wrote. Where the division begins.
- Copy and paste the entire fragment into a separate file and name it
elm-core.js TA-dah! Now you can load them into HTML files:
<html> <script src="elm-core.js"></script> <script src="output.js"></script> </html>
Caution! The entire output packet is wrapped in IIFE (the function expression is called immediately), so you have to wrap all the pieces in this to make sure that it works. If you do not, you will get errors such as F2 not defined "and" A2 - undefined ".
Elm 0.19 +
Future versions of Elm should have a better solution to this problem.
Rudolf olah
source share