06 January 2015
At this point there are a couple of options - break apart the code and only use what you need when you need it through asynchronous module loading. While this works OK for library dependencies, for your application modules you'll likely as not be fighting race conditions if you don't exert some discipline. Surmountable for sure, but certainly not as simple to reason about as a single concatenated file.
The other option is to use smaller dependencies. The problem with this is that the microlib of yesterday may very well become the macrolib of tomorrow. The fully internationalized version of moment.js is as big as jQuery & Underscore.js combined!
There is an alternative solution to this problem that's rarely discussed.
But just how good is it in practice?
Consider the following ClojureScript program. It includes DateTime formatting, DateTime arithmetic, and internationalization:
(ns practice.core (:import [goog.date DateTime Interval] [goog.i18n DateTimeFormat])) (def f (DateTimeFormat. "EEEE MMMM d, y")) (let [week (Interval. nil nil 7) dt (DateTime.)] (.add dt week) (.log js/console (.format f dt)))
If I want this ClojureScript program to emit a DateTime string in French the total cost of this entire program will be ~4K gzipped. That's 10X less of a dependency than moment.js with internationalization.
If you're a ClojureScript developer I highly recommend always first checking to see if there isn't a satisfactory Google Closure module that will get the job done. Just the other day I needed a pseudorandom number generator for test.check, Closure did not disappoint.