April 2, 2020
Estimated Post Reading Time ~

Client Libraries are not Refreshing Automatically in AEM/CQ5

Issue 1:
The issue is that sometimes when I update my javascript client libraries (under /etc/designs/my_project/clientlibs), the changes are not always automatically reflected when I refresh my webpage to test. One way around this is to clear your browser cache after making a change, but depending on the situation, that might mean logging into either CQ5 again or your even the website you’re working on in order to test the changes.

What I found is that if you make a change to the js.txt file in your client library and save it again, then the changes in the actual javascript file you’re working on are picked up.

For example, I have the following js.txt in my clientlibs_main (cq:ClientLibraryFolder) folder:


#base=/etc/designs/my_project/clientlibs 
js/my_client_javascript.js

and my actual javascript functions are in the file /etc/designs/my_project/clientlibs/js/my_client_javascript.js. When I make changes in my_client_javascript.js, these aren’t always reflected in the website after saving. But after making my change, if I edit js.txt (I generally delete and re-add the ‘s’ at the end of the line ‘js/my_client_javascript.js’), and save THIS file as well, the changes are reflected in the website without the need for clearing the browser cache.


Issue 2:
There is another issue with client libraries that has been introduced in AEM (CQ5.6).

When you create a new client library (cq:ClientLibraryFolder) in AEM, it is not automatically registered in the system as it was in CQ5.5. This means that although your code is there, it cannot be used until Sling recognises it. Adobe are planning a fix for this in a future Service Pack, but until that is released there is a manual workaround.

Navigate to the Html Library Manager in the OSGi console at http://localhost:4502/system/console/components/com.day.cq.widget.impl.HtmlLibraryManagerImpl and stop the component. After the component has been stopped, the page refreshes and the component is not visible anymore – refresh the browser and start the component again. Now your client library will be registered and should be working.

Note that this only applies to newly added client libraries. If you edit an existing client library then you should not need to use this fix.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.