Creating a Client Library in AEM:
- Create a new folder for the client library under the
/appsdirectory. The convention for naming client library folders is
clientlibs.<name>.For example, to create a client library named
myclientlib, create a new folder
- Inside the
myclientlibfolder, create a
- Create a
clientlibnode under the
myclientlibfolder using the
nt:foldernode type. This node will hold the client library definition.For example, create a new node
- Set the properties of the
clientlibnode to define the client library. The following properties can be set:
jcr:title: The title of the client library.
jcr:description: A description of the client library.
categories: An array of categories that the client library belongs to. Categories can be used to group client libraries and control their loading order.
allowProxy: A Boolean flag indicating whether the client library can be served by a reverse proxy.
For example, to set the title and categories of the
myclientlibclient library, set the following properties:
jcr:title = My Client Library categories = [mycategory]
categoriesproperty is optional, but it is recommended to use it to group and organize client libraries.
categoriesnode under the
clientlibnode, using the
For example, create a new node
categoriesnode using the
cq:includenode type. The
cq:includenode has the following properties:
myscript.jsand a CSS file named
mystyle.css, create the following nodes:
/apps/clientlibs.myclientlib/js/myscript.js /apps/clientlibs.myclientlib/css/mystyle.css /apps/clientlibs.myclientlib/clientlib/categories/js cq:include (nt:file) file = /apps/clientlibs.myclientlib/js/myscript.js /apps/clientlibs.myclientlib/clientlib/categories/css cq:include (nt:file) file = /apps/clientlibs.myclientlib/css/mystyle.css
- Include the client library in your AEM pages or templates. To do this, use the
clientlibSling tag in your JSP files.
For example, to include the `myclient