Skip to content

Optimize Elm code with uglify-js 3 #2127

Closed
@David-Klemenc

Description

@David-Klemenc

Quick Summary: Instructions for optimization script should be updated for the new backwards incompatible version of uglify-js

SSCCE

#!/bin/sh

set -e

js="app.js"
min="app.min.js"

elm make --optimize --output=$js $@

# piping no longer needed !?
uglifyjs $js --compress "pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe" --mangle --output $min

echo "Initial size: $(cat $js | wc -c) bytes  ($js)"
echo "Minified size:$(cat $min | wc -c) bytes  ($min)"
echo "Gzipped size: $(cat $min | gzip -c | wc -c) bytes"
  • Elm: 0.19.1

Additional Details

With the new version of uglify-js (tested with uglify-js 3.10.0) piping is no longer needed (I tested with a 20 kloc elm program - and it works as expected)

Pages that should be updated:

EDIT

Switched to terser

# ...
terser $js --compress "pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe" --mangle --output=$min
# ...

as per PR#2076

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions