Optional self-hosting

This page documents advice for people wanting to build ClojureScript
projects that want or need to leverage cljs.js/eval-str and other
self-hosted functionality.

If you are building a web application where the final size
of the deployed artifact matters significantly, you should not be using
any of the functionality outlined on this page.

Production Builds

You can leverage up to :optimization :simple with builds that include
the cljs.js namespace. Other recommended settings:

:pretty-print false
:optimize-constants true
:static-fns true

:optimize-constants is significant for code size, all literal keywords
and symbols in your source will be compiled into a single lookup table.

:static-fns true is especially important if you are targeting Safari /
JavaScriptCore. (See
CLJS-1381 for details.)

By default for ease of use cljs.js/empty-state will dump the analysis
cache for cljs.core directly into the cljs.js namespace. This
doubles the size of the final artifact. You can disable this with
setting :dump-core false in your compiler build options.

This means you will need to load the analysis for core yourself. It’s
easy to dump the core analysis cache. In your ClojureScript project load
a Clojure REPL and do something like the following: