Webjars
This plugin (previously known as feature) enables serving static content provided by webjars. It allows you to package your assets such as javascript libraries and css as part of your uber-jar.
Add dependencies
To enable Webjars
support, you need to include the ktor-webjars
artifact in the build script:
Install Webjars
To install the Webjars
plugin, pass it to the install
function in the application initialization code. Depending on the way used to create a server, this can be the embeddedServer
function call ...
... or a specified module.
Configure Webjars
This configures the plugin to serve any webjars assets on the /assets/
path. The zone
argument configures the correct time zone to be used with the Last-Modified
header to support caching (only if Conditional Headers feature is also installed).
Versioning support
Webjars allow developers to change the versions of the dependencies without requiring a change on the path used to load them on your templates.
Let's assume you have imported org.webjars:jquery:3.2.1
, you can use the following html code to import it:
You don't need to specify a version, should you choose to update your dependencies you don't need to modify your templates.