Releasing `elmjs-inspect`

Why is your elm.js file so big?
Is Elm’s dead code elimination on a particular function not working as you expected?
What libraries cost your users bandwidth?
Analyse your elm.js file size with this tool.

elmjs-inspect

I’ve had a couple of scripts lying around that would parse the elm.js file that your elm code compiles into and would give you a sorted list of functions and how much percent of bytes it takes up in that file.

With a bunch of help from @miniBill and more recently @pdamoc it’s now a little more polished (thanks!): It’s uploaded to npm, so you can simply install the CLI via npm i elmjs-inspect and run it like this:

$ elm make src/Main.elm --output=elm.js
Success!     

    Main ───> elm.js

$ elmjs-inspect elm.js --summary=package
37.601%: author/project
33.004%: Kernel Code
12.632%: elm/core
5.022%: elm_community/typed_svg
2.360%: mpizenberg/elm_pointer_events
1.872%: elm/json
1.322%: elm/url
0.649%: elm/html
0.572%: elm_community/list_extra
0.557%: elm/virtual_dom
0.487%: avh4/elm_color
0.120%: elm/browser
0.039%: elm/svg
Range sum: 231878 total: 240946, analyzed 96.237%

You can also pass other things to get different levels of summaries:

$ elmjs-inspect --help
Usage: elmjs-inspect [options] <filename>

Analyse your elm.js file size with this tool.

Arguments:
  filename               The file to analyze

Options:
  -V, --version          output the version number
  -s, --summary [value]  Display summary. Possible values: module, package, project
  -h, --help             display help for command
37 Likes

I have installed the tool and used it.
Fine! Earlier, I could just optimize the js with a script.
(using elm make --optimize, uglifyjs --compress --mangle)

Now, I can analyze the compiled codes too.

$ ./optimi2.sh suncalc-22.elm
Success! Compiled 1 module.

    Main ───> elm.js


Compiled size:  136443 bytes  (elm.js)
Minified size:   35824 bytes  (elm.min.js)
Gzipped size:    12579 bytes

$ elmjs-inspect elm.js --summary=package

57.932%: Kernel Code
19.024%: author/project
10.491%: elm/core
2.988%:  elm/json
2.271%: elm/url
1.097%: elm/html
0.445%: elm/browser
0.309%: elm/virtual_dom
Range sum: 129010 total: 136435, analyzed 94.558%
$ elmjs-inspect elm.min.js --summary=package
Range sum: 0 total: 35816, analyzed 0.000%

$ ll *.js
-rw-r--r--  1 136443 18 Aug 01:31 elm.js
-rw-r--r--  1 35824  18 Aug 01:31 elm.min.js
2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.