load clientLib based on components(CQ.AUTHORING.DIALOG GETS LOADED ON ALL THE PAGES OR ALL THE PROJECTS) | Community
Skip to main content
Level 2
Nov 22, 2016 3:22 AM UTC
Solved

load clientLib based on components(CQ.AUTHORING.DIALOG GETS LOADED ON ALL THE PAGES OR ALL THE PROJECTS)

we have defined components clientLibs as cq.authoring.dialog, But these js libs will be loaded for all templates(all projects) while authoring the pages.

Can we restrict them based on template or components as these JS may create issue in other AEM projects?

I tried extraClientLibs but its not working properly..

Is there anyway other then overlaying out-of-box components?

Thanks,

Malli

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
akashs51893872
akashs51893872Accepted solution
Level 3
Aug 8, 2018 1:02 AM UTC

Hi mallipanchal,

I solved this problem by inserting two lines of HTL code in the component HTML itself.  PFA the screenshot:

You need to have a clientLibraryFolder created with this category name:

Now, ONLY wherever you have this component, the JS/CSS files for this component will be loaded.

Good Luck...

12 replies

arunpatidar
New Participant
Nov 14, 2018 1:12 PM UTC

For touch UI dialog specific clientlibs you can add via extraClientlibs property

How to Load TouchUI dialog Specific Clientlibs

Translate
Arun Patidar
Level 2
Nov 14, 2018 11:27 AM UTC

Any way we can segregate libraries depending upon claasic/touch UI

I want to keep both dialogs types in component, but the libraries (custom.js) need to be seperately called in case of touch UI and other s when I open dialog in classic.

Translate
akashs51893872
Level 3
Oct 31, 2018 10:42 AM UTC

+ antoniom54959291​, kautuksahni​, smacdonald2008​

Hi mallipanchal,

There is one more solution to this. In the client-library that has the category `cq.authoring.dialog`, you can include a sort of name-spacing.  For ex:

Good Luck...

Translate
akashs51893872
akashs51893872Accepted solution
Level 3
Aug 8, 2018 1:02 AM UTC

Hi mallipanchal,

I solved this problem by inserting two lines of HTL code in the component HTML itself.  PFA the screenshot:

You need to have a clientLibraryFolder created with this category name:

Now, ONLY wherever you have this component, the JS/CSS files for this component will be loaded.

Good Luck...

Translate
smacdonald2008
Level 10
Nov 24, 2016 11:27 AM UTC

Include the clientlib in the script that corresponds to the component. If its a page component - place it there. 

Translate
Level 2
Nov 24, 2016 3:38 AM UTC

smacdonald2008 wrote...

I spoke to some of our experts - it lines up with my 1st response. 

If not needed for all projects or templates it is better not to attach to cq.authoing.dialog and use cq:includeClientLib with a new category

(introduce a new clientlib that contains CSS or JS.) 

 

 

Where should I include it in page component or in any of the particular components script.( I hope we need this only in EDIT mode)??

Translate
Level 2
Nov 24, 2016 3:35 AM UTC

antoniom54959291 wrote...

I've a similar issue, but i fix it just creating a new clientlibrary named custom.authoring.dialog and including it by using extraClientLibs in our components.

 

Yeah, Even I tried this. BUT

Using extraClientlib property on the cq:dialog, This can be done  but issue here is dialog DOM elements and JS lib were loaded at the same point syncing is not happening. so when we open dialog first time its not working, close the dialog and open it again it works fine(JS were loaded in first time, so it works fine second time onwords).

Note: we are using custom-multifield.

Translate
antoniom5495929
Level 7
Nov 23, 2016 5:02 PM UTC

I've a similar issue, but i fix it just creating a new clientlibrary named custom.authoring.dialog and including it by using extraClientLibs in our components.

Translate
smacdonald2008
Level 10
Nov 23, 2016 3:39 PM UTC

I spoke to some of our experts - it lines up with my 1st response. 

If not needed for all projects or templates it is better not to attach to cq.authoing.dialog and use cq:includeClientLib with a new category

(introduce a new clientlib that contains CSS or JS.) 

Translate
Level 2
Nov 23, 2016 9:33 AM UTC

kautuksahni wrote...

Hi 

Please have a look at this community article for AEM Client Libraries best practices.

If you want to create component specific clientlibs then you need to create a new clientlibs that gets applied to that particular component. See the article to know how to do it.

Link:- http://blogs.adobe.com/experiencedelivers/experience-management/clientlibs-explained-example/

This article will explain:

  • multiple components with their own JavaScript and CSS files
  • global JavaScript and CSS files
  • apps folder is not available on the publish instance
  • CSS resources have to go in the <head>, JavaScript resources at the end of the page
  • Resources need to be minified
  • Some resources need to be merged

I hope this would help you.

~kautuk

 

By this method we can load site specific styles and JS. But I want include TouchUI dialog specific JS in editmode. Currently we used id as cq.authoring.dialog(but these JS loads in all pages or in all project components while editing )

Translate