WebJars is a packaging of static resources so that they are available to JVM-based containers and Web frameworks. For instance, with a Servlet 3 container, you only need to add a WebJars-packaged version of a library, like Bootstrap, to your classpath and the static files contained within will be available from your Web application.
For instance, add the following to a Maven pom.xml file and a Jetty server running from within the build will be able to provide access to the Bootstrap files.
<dependencies> <dependency> <groupId>org.webjars</groupId> <artifactId>bootstrap</artifactId> <version>3.2.0</version> </dependency> </dependencies>
Your HTML only needs to contain the following reference:
<link rel='stylesheet' href='webjars/bootstrap/3.2.0/css/bootstrap.min.css'>
This works outside of the Maven context as well. Drop a WebJar into your Tomcat 7’s
WEB-INF/lib directory and the static files contained within are accessible at the WebJars path. WebJars also work with the Play Framework, Grails, Ring (Clojure), and others.
In addition to being packaged within a jar file, these static files are also made available from jsDelivr, a free Content Delivery Network (CDN). For instance, see:
It’s been accepted and published through the WebJars site. So, OpenSeadragon 1.1.1 is now also available from jsDelivr:
and from the following path, if the WebJars-OpenSeadragon jar is installed in your servlet container’s classpath:
To include WebJars-OpenSeadragon in a Maven-based project, you just need to include the following as a dependency in your pom.xml file.
<dependencies> <dependency> <groupId>org.webjars</groupId> <artifactId>openseadragon</artifactId> <version>1.1.1</version> </dependency> </dependencies>
My project contains a test subproject that uses WebJars-OpenSeadragon (if you’d like an example of using a WebJar from the Maven context). It also includes an HTML example of how to configure OpenSeadragon when using WebJars-OpenSeadragon:
It’s that easy. My next step is to upgrade my djatoka fork to reference the OpenSeadragon WebJar (rather than provide it’s own repackaged version of OpenSeadragon). Thanks to the WebJars (and OpenSeadragon) folks for providing access to such fine tools!