Expand my Community achievements bar.

SOLVED

Serve Client Libraries from specific folders

Avatar

Level 2

So client libaries are stored and cached in cq in /var/clientlibs.

Is there any way to serve these files from that directory?

For example we have client libraries with our components in our apps directory.  Currently using client libraries we are including them from the place the components lives for example if i create a component under

/apps/test/myComponent

I then create a client library for this and place the client library include in my jsp.

CQ will cache this for me under /var/clientlibs/ but it will still serve them from the apps directory.  Is there a way to make this be served from teh var directory instead in my html so it won't be blocked by the dispatcher?

 

Thanks in advance!

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi,

The correct way to handle that situation is to create a clientlib under /etc which embeds the clientlib under /apps.

View solution in original post

4 Replies

Avatar

Correct answer by
Employee

Hi,

The correct way to handle that situation is to create a clientlib under /etc which embeds the clientlib under /apps.

Avatar

Level 2

Hi! Thanks for replying!

I understand totally what you are saying and I understand that concept.  My problem is that we have a large number of applications and if we embed them in client library categories in our etc folder then we will get more css and js than we really need or we would have to create a client library for every one of the components we have that has css and js that must be isolated to that component (for example have a single page with one component on it).  Is there any way to serve them from the /var/client libs at all?

Avatar

Employee

Hi,

It sounds like you've overengineered this a bit. Your are better off (both in CQ and in general) serving fewer JS/CSS files, even if those files contain rules which don't apply on specific pages. If you're using minification and gzipping (which you should be), the additional rules/code are trivial in length compared to the network roundtrip of fetching them separately. Most of the time, my projects use a single end-user facing client library (which might embed some other libraries of course). It is the relatively rare case where a separate library is necessary. Of course, every project is different, so YMMV.

So I would create one library in /etc which embeds all the other libraries. And then just reference that library in your JSP code.

Justin

Avatar

Level 10
You can either place under apps for components under each app or under /etc as Justin suggested.