This repository has been archived by the owner. It is now read-only.
A ring wrapper serving webjars
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

This project is not maintained anymore. You might want to use ring-webjars instead.

clj-webjars Travis CI status

A ring wrapper to easily serve assets.


Add [clj-webjars "0.9.0"] to your leiningen dependencies.


Define wrap-webjars as part of your handler stack to serve webjars. Then call refresh-assets! to trigger discovery/loading of all webjars that will be available through the wrapper. refresh-assets! accepts filters/class-loaders as argument to control which assets will be exposed.

By default all requests whose URI match assets/js, assets/css or assets/img will be served (alternatively provide custom root URIs using (wrap-webjars ["assets/js"])). Extra part of the URI will be used to match the asset among your declared webjars.

Assets are served from memory and honor caching semantics (i.e. return status code 304 when needed).


Following is a complete example showing how to serve bootstrap webjar.

;; define your main ring handler
(defn handler [request]
  {:status 200
   :headers {"Content-Type" "text/html"}
   :body "Hello World"})

;; trigger assets refresh

;; use wrap-webjars
(defn -main[]
  (run-jetty (-> handler (wrap-webjars)) {:port 3000}))

Add bootstrap webjar to your leinigen dependencies: [org.webjars/bootstrap "2.3.1"].

Now you can declare bootstrap css in your html file:

<link rel="stylesheet" href="assets/css/bootstrap.min.css">

Or just check using curl:

curl http://localhost:3000/assets/css/bootstrap.min.css


Copyright © 2013 Julien Eluard.

Distributed under the Eclipse Public License, the same as Clojure.