69

My coworker complained about an way to big Angular build (20 MB in prod!).

We looked over his code.
... Well deleting that 200 unused base64 encoded images shrinked it down to 500kB

DELETE the Code you replace

Comments
  • 4
    Such an idiot
  • 3
    @irene actually they were inside a provider which was imported somewhere else.
    But it is unused for a few months now.

    So a dead import kept the compiler and the optimizer away 😁
  • 1
    @irene ng build - -prod
    magicπŸ˜‚
    It's not my project I'm just helping over the table 😁
  • 1
    Oh... And the typescript compiler of course
  • 1
    @irene Its Babel transpiling Typescript and/or ES6 -> plain JavaScript.
  • 3
    @irene it shakes a tree... I legit think it just shakes a tree.
  • 1
    @irene with a minifier, definitely.

    But ES5 ("vanilla js") is more verbose than ES6, so without it the size often increases!
  • 2
    @irene πŸŒ²πŸ‘‹πŸ»
  • 1
    @irene Oh. The transpiler doesn't check code paths to see what's reached and what isn't (or if it's functional). It just transpires everything you throw at it.
  • 1
    @irene this is an ideal starting place for a rant about how terrible web development really is compared to systems development / embedded systems / game design / literally anything else. 😧
  • 2
    @irene @root actually... Put "module" in your sentence and it'll be accurate. If properly set up, ts will only transpile the files in your dependency tree.
    If you require a file, it'll transpile the whole thing and leave alone the ones you don't.
    Getting parts of it, is what's called tree shaking and that's your build tool's job (webpack)
  • 1
    @HeiLian well yes. But what I was explaining to @irene is that it'll add included-but-not-used code to the build. That's why OPs build shrank so much.
  • 1
    @irene πŸ˜… I used to, too.

    And "code" for interpreted languages instead of "script" -- guess I've gotten over that.
  • 1
    @irene sure... Which word would you use instead? Building doesn't imply nor mean compiling
Add Comment