Skip to content
Demonstration of how to use third party JS in ClojureScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
resources/public Initial setup Sep 19, 2016
src Initial setup Sep 19, 2016
project.clj Initial setup Sep 19, 2016


A demonstration of the various ways to consume a third party library from ClojureScript.

For the full background on these approaches, watch out for the upcoming Lambda Island episode, "Using JavaScript libraries from ClojureScript".


Check out the relevant branch, then build the project

lein cljsbuild once dev

and open resources/public/index.html in your browser.

You can also try advanced compilation, which works for some setups, but not for others.

lein clean
lein cljsbuild once prod


Use D3 from . Works for both dev and prod builds

Use D3 from by loading it from a CDN. Works only for the dev build.

Liks script-d3, but add externs for the features we're using. Advanced compilation works again.

Like script-d3-externs, but with auto-generated externs.

Implements leftPad as a Google Closure module, loads it by putting it on the classpath.

Compile D3 to a single ES6 file with Rollup, then use that directly with :module-type :es6. Broken for advanced compilation, probably because D3 violates some of the Closure assumptions. (Lots of warnings on advanced compilation).

Include D3 with :foreign-libs and :externs. This is what CLJSJS currently does. Works for advanced compilation.

Another example of using the ES6 module support, but with a twist: the ES6 module in turns depends on a CLJS namespace. Full ES6/ClojureScript interop, how cool is that?


Copyright © 2016 Arne Brasseur

Distributed under the Mozilla Public License 2.0

You can’t perform that action at this time.