You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: hints/optimize.md
+5-7
Original file line number
Diff line number
Diff line change
@@ -15,20 +15,18 @@ Okay, but how do we get those numbers?
15
15
16
16
Step one is to compile with the `--optimize` flag. This does things like shortening record field names and unboxing values.
17
17
18
-
Step two is to call `uglifyjs` with a bunch of special flags. The flags unlock optimizations that are unreliable in normal JS code, but because Elm does not have side-effects, they work fine for us!
18
+
Step two is to call `terser` with a bunch of special flags. The flags unlock optimizations that are unreliable in normal JS code, but because Elm does not have side-effects, they work fine for us!
19
19
20
20
Putting those together, here is how I would optimize `src/Main.elm` with two terminal commands:
After this you will have an `elm.js` and a significantly smaller `elm.min.js` file!
28
28
29
-
**Note 1:**`uglifyjs` is called twice there. First to `--compress` and second to `--mangle`. This is necessary! Otherwise `uglifyjs` will ignore our `pure_funcs` flag.
30
-
31
-
**Note 2:** If the `uglifyjs` command is not available in your terminal, you can run the command `npm install uglify-js --global` to download it. You probably already have `npm` from getting `elm repl` working, but if not, it is bundled with [nodejs](https://nodejs.org/).
29
+
**Note:** If the `terser` command is not available in your terminal, you can run the command `npm install terser --global` to download it. You probably already have `npm` from getting `elm repl` working, but if not, it is bundled with [nodejs](https://nodejs.org/).
It also prints out all the asset sizes for you! Your server should be configured to gzip the assets it sends, so the last line is telling you how many bytes would _actually_ get sent to the user.
57
55
58
-
Again, the important commands are `elm` and `uglifyjs` which work on any platform, so it should not be too tough to do something similar on Windows.
56
+
Again, the important commands are `elm` and `terser` which work on any platform, so it should not be too tough to do something similar on Windows.
0 commit comments