Needs to add custom js on each and every page in AEM | Community
Skip to main content
Level 3
May 23, 2023
Solved

Needs to add custom js on each and every page in AEM

  • May 23, 2023
  • 3 replies
  • 2885 views

Hi Team,

 

We want to add some custom JS on aem author instance on each and every page.

Can anyone please help me to suggest where I put this JS so that call on each page.

 

Thanks

Bhagchand

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 Himanshu_Jain

Add the js in author clientlibrary .

Ref : https://sourcedcode.com/blog/aem/adding-custom-client-library-for-aem-author-editor-touch-ui

 

3 replies

Himanshu_Jain
Community Advisor
Himanshu_JainCommunity AdvisorAccepted solution
Community Advisor
May 23, 2023
bhagchandAuthor
Level 3
May 24, 2023

Thanks a lot, let me check

Rohit_Utreja
Community Advisor
Community Advisor
May 23, 2023

Hi @bhagchand,

 

In addition to Himanshu's comment earlier, if you have a common clientlibs and need to be loaded only in author mode, you can add it in the page component and restrict it only to author mode.

 

<sly data-sly-test="${wcmmode.preview || wcmmode.edit}" data-sly-call="${clientLib.all @ categories='category.name'}"/>

 

I hope it helps.

 

Regards,

Rohit

bhagchandAuthor
Level 3
May 24, 2023

Thanks let me check

Umesh_Thakur
Community Advisor
Community Advisor
May 24, 2023

@bhagchand , is this js required for any dialog validation or dialog function or any direct functionality on the page?

I am asking this because you mentioned AUTHOR instance.

bhagchandAuthor
Level 3
May 24, 2023

Hi @umesh_thakur ,

Basically we want admin user logged out after 15 mins inactivity.

we also changed apache token expiration configuration from admin but it will forcefully logged out user after 15 mins.

 

So from the JS we can manage like this.

 

https://social.msdn.microsoft.com/Forums/en-US/3ce8cbd1-e1a1-430f-b32a-a6456a33a8de/if-no-activity-for-15-minutes-display-an-alert-on-web-page-and-then-either-continue-or-logout?forum=aspstatemanagement  

Umesh_Thakur
Community Advisor
Community Advisor
May 24, 2023

what all will be included in user activity ? will it be limited to content authoring or it will be extended to any activity by the author like changing system configuration, making any change in workflow model etc?

Normally mouse click or key pressing are being taken as activity? so can you confirm that as well 

based on this answer we can decide the approach thru JS or thru any server side implementation.