23

I have tried to add multiple categories to embed[] and dependencies[] interchangeably many times. But I always see a dependency resolution error in JavaScript on the website.

Also, How do I specify the order of categories in a multiple value entry like embed[]? Is there any way we can control the order the JavaScript source that is loaded during the launch of website?

exception
  • 955
  • 2
  • 11
  • 23

2 Answers2

36

categories is the list of identifiers to publish a clientlib under.

dependencies should cause your page to have extra requests to other clientlibs (external "subscribe")

embed should "aggregate" those other clientlibs INTO the current clientlib (internal subscribe)

both properties can have multiple values, and the CRXDE Lite interface allows changing the order of items in the value list.

Given Clientlibs:

  • /etc/clientlibs/depA categories=["depA"]
  • /etc/clientlibs/depB categories=["depB"]
  • /etc/clientlibs/depC categories=["depC"]
  • /etc/clientlibs/useA categories=["useA"], dependencies=["depA", "depB"]
  • /etc/clientlibs/useB categories=["useB"], embed=["depB", "depC"]

If a page uses "useA" <cq:includeClientLib categories="useA"/>, then the HTML should have requests for depA, depB, useA (through their appropriate urls, ie /etc/clientlibs/depA.css

If a page uses "useB" <cq:includeClientLib categories="useB"/>, then the HTML should have only a request for useB. The contents of /etc/clientlibs/useB.css would be the concatenation of contents of depB, depC, useB.

The library manager at {localhost}/system/console/configMgr/com.day.cq.widget.impl.HtmlLibraryManagerImpl has a debug configuration to determine if the requests are ACTUALLY concatenated. This is documented at http://dev.day.com/docs/en/cq/current/deploying/configuring_osgi.html#par_variable_18

To define multiple dependencies (assuming you are using maven to build from your filesystem and install into CQ5), the clientlibs folder will have a file ".content.xml" that needs the following attribute:

dependencies="[depB,depC]"
IT Gumby
  • 1,067
  • 8
  • 11
  • 12
    One detail is missing though: Dependencies are transitive, Embeds are not. Exemples: A depends on B which embeds C -> C+B and A are loaded. A embeds B which depends on C -> B+A are loaded, C is not. This can be tricky if you want to embed some CQ libraries (to request one single JS), and those libraries depends on other CQ libraries. You then need to embed all of them, in the right order. – Romain F. Aug 20 '14 at 14:26
  • I should add that `categories` are meant to abstract away from the directory structure. Therefore, it is NOT helpful to create category labels that essentially mimic the folders. – IT Gumby Sep 08 '16 at 18:55
1

to check the required clientlibs for embed, you can use ClientLibs Optimizer Tool from: https://adobe-consulting-services.github.io/acs-aem-tools/features/clientlibs-optimizer/index.html It also gives you the order in which you should be keeping the embed clientlibs

OmP
  • 189
  • 1
  • 3
  • 21