I created a library that I only want to be loaded in authoring/editor environments.
Solved! Go to Solution.
Views
Replies
Total Likes
I have found a solution.
I created a new library and made it a dependency of my old library that was added in page.js.
This way my code was loaded in a separate file and that file had the new code.
How to do that you can read here
Not perfect or but hey it worked.
Thanks all for contributions.
Hi,
If you need your JavaScript to load when your component's dialog opens, you can use something like this: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/modify-dialog-value-after-...
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:ClientLibraryFolder"
categories="cq.authoring.dialog"/>
If you want your JavaScript to load when the Page editor loads, something like the example below should work:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:ClientLibraryFolder"
categories="cq.authoring.editor.sites.page.hook"
dependencies="cq.authoring.editor.sites.page"/>
If you are trying to override a core component clientlib, you may need to check this: https://www.youtube.com/watch?v=0T9w8XCwtYA
Hope this helps
Hi.
The second option is correct. I want to load my JS when the Page editor loads.
I have changed to code to your example and again locally it works fine, but in testing environment page.js with old version of the code is loaded.
I even tried the ?cache busting method but I still get the old library.
Is there any non-ideal workaround where I could try placing the library that it would load ok?
If this is happening on a test env and not locally one area to look at would be caching as often locally you would not be going via dispatcher etc which could be caching. You could check this on your test env by appending query string params to the file path which would bypass dispatcher cache and force a load from the AEM instance.
you could enable clientlib versioning which would ensure the JS file path changes if the underlying files which make up the clientlib are modified.
I tried to append ?givemenewversion="10" to my page in testing environment but I still get the old code in page.js
I think we have clientlib versioning enabled for clientlib-site but probably not for page.js. Is that even a clientlib?
are you able to share the full path of the page.js file which isn't updating?
I also asked around for versioned clientlibs and devs said they turned it off because it was causing issues in other environments.
@MichaelNeu007 Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes
I have found a solution.
I created a new library and made it a dependency of my old library that was added in page.js.
This way my code was loaded in a separate file and that file had the new code.
How to do that you can read here
Not perfect or but hey it worked.
Thanks all for contributions.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies