How to determine which clientlib to use - AEM 6.0 | Community
Skip to main content
soares_bs
Level 2
November 9, 2017
Solved

How to determine which clientlib to use - AEM 6.0

  • November 9, 2017
  • 2 replies
  • 1019 views

Hey guys,

I'm working on a task that I consider a kind of challenge. So, that's the deal.

I need to programmatically determine which clientlib to use. for example, if a website has already the AngularJS then I would call a specific clientlib with a non-AngularJS dependency and vice-versa,

This could be used on a website where AngularJS is already used, and it could be used on a website where AngularJS is not being used (and needed as a dependency).

If you guys could help me with this, I really would appreciate it.

Thanks for sharing.

Have a good one!!!

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 kautuk_sahni

It is not recommended to create conditional logic or wrapper to decide which Script/CSS/Client lib to be used. As this introduce delays in the process and might be technically not supported.

Whereas we can certainly do this by creating conditionally lading of JS:

     var head = document.getElementsByTagName('head')[0];

     var js = document.createElement("script");

     js.type = "text/javascript";

     if (condetion 1)

     {

         js.src = "js/jquery_computer.js";

     }

     else

     {

         js.src = "js/mobile_version.js";

     }

     head.appendChild(js);

Related Reference post:- Using common template for differnt project having different css

~kautuk

2 replies

kautuk_sahni
Community Manager
kautuk_sahniCommunity ManagerAccepted solution
Community Manager
November 10, 2017

It is not recommended to create conditional logic or wrapper to decide which Script/CSS/Client lib to be used. As this introduce delays in the process and might be technically not supported.

Whereas we can certainly do this by creating conditionally lading of JS:

     var head = document.getElementsByTagName('head')[0];

     var js = document.createElement("script");

     js.type = "text/javascript";

     if (condetion 1)

     {

         js.src = "js/jquery_computer.js";

     }

     else

     {

         js.src = "js/mobile_version.js";

     }

     head.appendChild(js);

Related Reference post:- Using common template for differnt project having different css

~kautuk

Kautuk Sahni
smacdonald2008
Level 10
November 10, 2017

Kautuk is 100% correct