Including client libraries | Community
Skip to main content
vivs92490136
Level 2
November 13, 2017
Solved

Including client libraries

  • November 13, 2017
  • 5 replies
  • 2033 views

Are there any disadvantages of including a clientlib through its path using <link rel="stylesheet"> and <script src=""> tags rather than its category name using the cq:includeClientLib tag?

For eg. if the client lib path is /etc/designs/myapp/clientlibs

will there be any problem if we include the css as <link rel="stylesheet" href="https://forums.adobe.com/etc/designs/myapp/clientlibs.css" type="text/css"> and js as <script src="/etc/designs/myapp/clientlibs.js"> tags instead of the cq:includeClientlib tag?

The reason, we want to do it this way is, we would like to add few selectors (like  /etc/designs/myapp/clientlibs.min.xyz123.css ) for minification and versioning of the CSS and JS libraries.

(Please note that enabling minification through HTML library manager is not an option for us for a different reason. Similarly, we cannot use the ACS commons clientlibs versioning for a reason.)

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

It would be interesting to know about your reasons, why you cannot use the library manager. In my current project we build the CSS and Javascript externally using a dedicated frontend-build toolchain and embed the resulting files into a clientlib. I don't see a reason why one would not use the clientlibrary mechanism.

Jörg

5 replies

smacdonald2008
Level 10
November 13, 2017

The way you mention works and from a technical viewpoint - no disadvantage that i can think of.

VeenaVikraman
Community Advisor
Community Advisor
November 13, 2017

As scott mentioned There is no disadvantage , it just that client libraries gives more flexibility . Its just a more organized way to handle your client side code. Its perfectly okay not to use those.

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
November 13, 2017

It would be interesting to know about your reasons, why you cannot use the library manager. In my current project we build the CSS and Javascript externally using a dedicated frontend-build toolchain and embed the resulting files into a clientlib. I don't see a reason why one would not use the clientlibrary mechanism.

Jörg

vivs92490136
Level 2
November 14, 2017

We are having a multi-tenant environment. Only some applications want minification to be enabled while others are not ready yet. Enabling minification through the HTML library manager in felix console applies it for all applications in the platform. Couldn't find a way to enable it specific to projects unless we customize the library manager itself. So the approach I mentioned is probably the simplest way to enable minification for some of the applications in the platform.

Level 2
November 14, 2017

Even when all CSS and JS files are getting minified automatically due to your configuration in Library Manager, you still can include the non-minified files in the approach you suggested: something.min.js vs something.js

With clientlibs, we get one CSS and one JS file. If trying to include files by path, you will have to include all the files yourself, increasing the number of requests. The worst place this hits is when Google starts considering your page slow due to more number of requests and rendering of blocking requests above the fold.