I'm trying to understand how dead code elimination works, and more specifically 
how I can get my production builds down to the smallest size possible.

If I compile this code with advanced optimization:

        (ns demo)

        (defn twice
          [x]
          (* x 2))

It compiles down to 139B. But if I add a couple of requires:

    (ns demo
      (:require-macros [schema.macros :as sm])
      (:require [schema.core :as s]))

    (defn twice
      [x]
      (* x 2))

The output is now 128K(!), even though it does nothing new. Since none of the 
required libraries are used, I wouldn't have expected them to make any 
difference. So why was my expectation wrong? What am I not understanding about 
dead-code elimination?

And perhaps more pressingly, what do I need to do to ensure the minimum file 
size under advanced optimizations? Is it likely that there's something in the 
way schema's written that's confounding the optimizer? Are there any known 
patterns I should be looking to patch?

If anyone out there's got the compiler-fu, I'd appreciate any pointers you can 
offer. We're about to push some ClojureScript into production (woo!) and 
obviously we'd like the compiled JavaScript to be as lean as possible.

Cheers,
Kris

PS - For reference, here's the code: 
https://github.com/krisajenkins/compilercheck

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to