All of the WebJar contents are available on the public jsDelivr CDN.
Just prefix //cdn.jsdelivr.net/webjars/{groupId} in front of your static asset URLs. For instance, if using
the org.webjars : jquery WebJar and your local URL to jquery.js is /webjars/jquery/2.1.0/jquery.js
then the CDN URL would be: //cdn.jsdelivr.net/webjars/org.webjars/jquery/2.1.0/jquery.js
WebJars can be added as dependencies to an app by simply adding them to the build.sbt file like:
libraryDependencies += "org.webjars" % "bootstrap" % "3.1.1-2"
Play automatically extracts the WebJar contents and makes them available via the Assets controller.
Xitrum can serve static files from classpath, which includes WebJars. See Xitrum documentation.
With any Servlet 3 compatible container, the WebJars that are in the WEB-INF/lib directory are automatically
made available as static resources. This works because anything in a META-INF/resources directory in a JAR
in WEB-INF/lib is automatically exposed as a static resource.
First add a WebJar as a dependency of your application in the pom.xml file, like:
<dependencies>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
Then simply reference the resource like:
<link rel='stylesheet' href='webjars/bootstrap/3.1.0/css/bootstrap.min.css'>WebjarsServlet allows Webjars resources to be referenced in legacy apps that are still running on Servlet containers that are not compliant with the Servlet 3 specification.
Register the webjars-servlet-2.x Maven dependency and WebjarsServlet in your web.xml.
With JSF, the WebJars that are in the WEB-INF/lib directory are automatically made available as resource
libraries. This works because WebJars are compatible with the JSF resource identifier format.
First add a WebJar as a dependency, then reference the resource like:
<h:outputStylesheet library="webjars" name="bootstrap/3.1.0/css/bootstrap.min-jsf.css" />Grails manages static resources with the resources plugin. The Grails Modules Manager plugin allows dependencies on web libraries to be declared in the Grails build configuration file.
With Dropwizard you can easily expose WebJars through the AssetsBundle.
addBundle(new AssetsBundle("/META-INF/resources/webjars", 0, "/webjars"));
Now you can reference a WebJar asset like:
<link rel='stylesheet' href='/webjars/bootstrap/3.1.0/css/bootstrap.min.css'>
Spring Boot automatically configures Spring to map requests for /webjars to the /META-INF/resources/webjars
directory of all the JARs in the CLASSPATH.
First add a WebJar as a dependency, then reference a WebJar asset like:
<link rel='stylesheet' href='/webjars/bootstrap/3.1.0/css/bootstrap.min.css'>
Spring MVC makes it easy to expose static assets in JAR files using ResourceHandlers.
Configure Spring to map requests for /webjars to the /META-INF/resources/webjars directory.
Apache Tapestry makes it easy to expose static assets in JAR files using contributeClasspathAssetAliasManager.
The Wicket integration of Webjars uses a special IResourceFinder implementation to map Webjars resources.
The Pippo integration of Webjars is pretty straightforward.
Ring makes it easy to expose WebJars through the wrap-resource function.
Dandelion provides a WebJars integration via a dedicated locator for WebJars.
The Vert.x Web StaticHandler
can resolve file paths from both the filesystem and the classpath.
Quarkus support the use of WebJars by default and also adds a WebJar Locator to reference WebJars without the version.
Add the webjars-locator-lite dependency and your WebJars, then define a routing path with the locator.