내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
해결됨

Load specific JS script on page load for every page in AEM just like Java Filters

Avatar

Level 2

Hello Devs,

I have one requirement where javascript code should load every time for every page.

I went through the clientlibs approach but below challenges I am having with current project -

1. They have multiple page components to Author different type of pages

2. There is no common clientlib i have observed till now which loads for every page

 

Please can anyone guide me what should be the correct approach to deal with such cases.

Thanks  

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

@sr1045 

 

If you utilise the WCM Core Components V2 Page, as your websites base page during the creation of the editable templates, you can utilize the editable template's Page Policies to set specific client libraries for different templates.

 

Please refer to screenshots on https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/load-site-specific-client-... 


Aanchal Sikka

원본 게시물의 솔루션 보기

4 답변 개

Avatar

Community Advisor

Hi @sr1045 ,

You may target template and add js at template level.

Most probably one page component overridden from core component would be getting used in all the template types( or even you may be having limited number of template)

You can create a clientlib category and can add in customfooterlibs.html of that page component which are getting used in all the template 

PFA

MukeshYadav__0-1721303645557.png

If it just few line of script tag like for gtm etc you can directly tadd that cript in head.html

So based on your use case you can add js centrally which will reflect in all the already created and future pages

MukeshYadav__0-1721305387133.png

 

Thanks,

Avatar

Level 2

Thanks @MukeshYadav_ 

Avatar

정확한 답변 작성자:
Community Advisor

@sr1045 

 

If you utilise the WCM Core Components V2 Page, as your websites base page during the creation of the editable templates, you can utilize the editable template's Page Policies to set specific client libraries for different templates.

 

Please refer to screenshots on https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/load-site-specific-client-... 


Aanchal Sikka

Avatar

Level 2

Thanks @aanchal-sikka