"categories (string) multiple - is the identifier used to directly include this clientlib from a content page or to embed it in other clientlibs. We can categorize our clientlibs using this property to manage files easily and only load whatever we need. The categories property, being multi-valued, allows a library folder to be part of more than one category."
I'm just try to understand the above. Can I have multiple clientlibs with the same "category" value in the .content.xml files ?
I tried it and it seems to work but I have some doubts if it is allowed.
I know all about "embed" and "dependency" etc. and I didn't use them here.
Just asking if I can use the above method. I know you can have a clientlib with multiple categories.
Now when component A is loaded we would expect this will also load the js and css included in component B and C. And so on.
So if this helps some how it should be ok to use the approach I suppose. Sorry for not having a sure answer but wanted to share what we could try to find a solution I will try this out as possible and update.
@fionas76543059 Yes you can have it. That is exactly why we use categories for. What AEM does is, it will compile all the files in the same categories to a single JS or CSS file and include it wherever that category is referred.
Let us say you have scenario where you are using same category name for two different projects
Proj X --> Clientlib Category AB
Proj Y --> Clientlib Category AB
When you include your Clientlib AB for you Project X , files in both project X and Y 's clientLibraries will be compiled and added as single file. Same way when you add the Clientlib AB in Project Y.
So when adding categories value , you have to keep this in mind. Categories can be same given you intend to use it along with the rest of the JS and CSS in Clientlibs with same category name elsewhere.
If your clientlibrary is your project specific , make sure to give unique category name so that unwanted JS or CSS doesn't get added to your project.
A simple example would be cq.authoring.dialog categories used in ClientLibraries , which we need to be added as part of the authoring dialogs to do some custom actions on the dialogs . If you use this category name in your ClientLib folder , it will add your JS or CSS to the rest of the files already under the same category in different locations and then compile them into one single file.