Class | Description |
---|---|
Adjunct |
In-memory cache of fully inlined "adjunct" which is a pair of CSS and JavaScript.
|
AdjunctManager |
This application-scoped object that exposes djuncts to URL.
|
AdjunctsInPage |
This request-scope object keeps track of which
Adjunct s are already included. |
Enum | Description |
---|---|
Adjunct.Kind |
Exception | Description |
---|---|
NoSuchAdjunctException |
A part of writing a web application involves reusing JavaScript libraries that are developed by 3rd parties. Such JavaScript libraries often come in a package of js files, CSS, images, and so on. To integrate those libraries to your application, you often need to do:
This tediousness hurts the small-scale reusability of JavaScript libraries. The adjunct framework in Stapler attempts to solve this by allowing libraries/components to express dependencies among themselves, and grouping CSS and JavaScript together, so that a single "inclusion" would include everything that a JavaScript library needs.
AdjunctManager
to URL by using Stapler. This object serves adjunct JavaScript, CSS, images, and so on.
<st:adjunct>
tag to load adjunct into the page. This tag expands to the <script>
and <link>
tags
for the adjunct itself and all the dependencies. It also remembers what adjuncts are already loaded into the page,
so when multiple <st:adjunct>
tags are used to load different libraries, it won't repeatedly load the same script.
Adjuncts are identified by their fully qualified names, which is the package name + base name of the file name (this is just like how a Java class gets its FQCN.)
Lines of the following form in JavaScript and CSS are interpreted by the adjunct framework to express dependencies to other adjuncts. They have to start at the beginning of the line, without a leading whitespace.
// @include fully.qualified.adjunct.name
/* @include fully.qualified.adjunct.name
HTML file can have the following line to indicate a dependency.
<@include fully.qualified.adjunct.name>
Stapler loads an adjunct into a page by generating a link tag and a script tag to load the JS and CSS files,
respectively. The URLs these tags point to are served by AdjunctManager
. If an HTML file is a part of an adjunct,
its content is just included inline along with script and link tags. This is useful to write a glue to load a large
3rd party JavaScript libraries without modifying them or changing their names.
Copyright © 2015. All rights reserved.