Clientlibs UI Extension | JS and CSS scripts are included multiple times
Description
Activity
Stefan Seifert September 16, 2024 at 9:35 AM
this issue somehow got overlooked - please note that it’s now fixed with https://github.com/wcm-io/io.wcm.wcm.ui.clientlibs/pull/5 and part of release 1.4.0

nimish kumar March 14, 2022 at 8:03 AM
Hi Stefan,
Thank you for the update. If we use the Adobe concept then we may end up in having scripts which are not needed for the page. The modern browsers are smart to load the js only once but there might be issues in the execution depending on the script content.
I think it is a good feature to add.
Stefan Seifert March 9, 2022 at 4:17 PM
we are using the same pattern as /libs/granite/sightly/templates/clientlib.html
from AEM itself which just includes the client libraries without checking for multiple occurrences. although it would be technically possible to implement such a behavior with workarounds like request attributes i would propose to follow the usual pattern in AEM: do not declare clientlibs within component which are used in containers. instead, declare client categories which ensure the required client libraries are included in the page where the components are used. this concept is not very elegant, but that’s what is given to us by Adobe.
I am using the client-lib template. The clientlib is included as part of component. If the component is present thrice on the page then I could see the JS and CSS files are included thrice.
Can we add some checks like to include js and css files only once ?