Expand my Community achievements bar.

SOLVED

overlay clientlibs

Avatar

Level 4

Hi, under
libs/xx/xx/clientlibs/Test.js
this clientlibs are loading in all aem pages by default
Now i want to customize the Test.js script in my project, is there any way to stop in pages to load Test.js clientlib and execute my js itself 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

If you want to run some custom logic on some pages, then rather than customizing it in some OOB /libs clientlib, I think you would be better off creating a new clientlib and loading it on your pages as per your requirement.
If you override the OOB clientlib and then load it on certain pages rather than loading it on all pages (as it is happening currently), chances are some other functionality which was dependent on the actual clientlib might start breaking on the pages where it is not loaded. 
hope this helps.

View solution in original post

3 Replies

Avatar

Level 5

Hi @user96222 ,

Could you please provide more details about your setup? Specifically, it would help to know:

  1. Where is the Test.js clientlib being loaded from? Is it included globally, such as in a page template (e.g., headlibs or bodylibs), or is it part of specific components?

  2. Do you want to exclude Test.js on all pages or just specific pages? Understanding if this is a global or page-specific change will help in deciding the best approach.

  3. Are you planning to replace Test.js with a custom script for specific functionality, or do you want to completely remove it and manage different scripts on different pages?

Avatar

Correct answer by
Community Advisor

If you want to run some custom logic on some pages, then rather than customizing it in some OOB /libs clientlib, I think you would be better off creating a new clientlib and loading it on your pages as per your requirement.
If you override the OOB clientlib and then load it on certain pages rather than loading it on all pages (as it is happening currently), chances are some other functionality which was dependent on the actual clientlib might start breaking on the pages where it is not loaded. 
hope this helps.

Avatar

Level 8

Hi @user96222 

in AEM you can customize almost anything. If you overlay the client lib and remove the category that is used to load it, it will stop loading on the page.

The question is why would you want to overlay an existing clientlib from Adobe? I never had that use case. You should create and load your custom client libs as @h_kataria suggested.

Ideally, you overload only the things you really, really need to...

 

Hope this helps,

Daniel