Loading clientlibs by component | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

7 replies

Ravi_Pampana
New Participant
Nov 10, 2018 7:27 PM UTC

Hi,

You can add clientlibs folder under each component and add category name to clientlibs folder like below

categories="[componentspecificname]"

Add the clientlibs inside component jsp/html

JSP:

<cq:includeClientLib categories="categoryname" /> -- This includes both js/css files

<cq:includeClientLib js="categoryname"/> -- To include only js

<cq:includeClientLib css="categoryname"/> -- To include only css

Sightly:

HTL and ClientLibs

This will include multiple js/css files on the page as each component will include a js/css files. Also, if clientlibs are added in /apps user everyone should have read access of /apps for files to load in publisher or clientlibs needs to create under /etc/designs

Translate
ariellea4070516
Level 3
Nov 10, 2018 7:29 PM UTC

I thought ‘cq’ was deprecated since AEM 5.3. Shouldn’t we be using ui now?

Translate
ariellea4070516
Level 3
Nov 13, 2018 6:40 PM UTC

Also, this solution injects clientlibs in the body of the page, which defeats the purpose of a component-based architecture (increasing the performance of an app) by forcing the client to re-render the page. And adding <link .. /> to the body is invalid, 'link' tags should only be added in the head of a document.

Translate
smacdonald2008
Level 10
Nov 9, 2018 11:31 PM UTC

You can call a clientlib from a specific component.

Translate
ariellea4070516
Level 3
Nov 9, 2018 11:34 PM UTC

So using ui:includeClientLib then? Ok, I'll need to find a way to rewrite the src's and href's because that approach exposes the internal structure of the application.

Translate