Search code examples
aemsightly

cq:includeClientLib in AEM if included inside a component jsp and the component is present twice on the page


If we give cq:includeClientLib inside my component jsp and if we drag and drop the component twice on that page, will the clientlib gets loaded/included twice?

what will be the case if we do in Sightly way (data-sly-call="${clientlib.all @ categories='somecategory'}") ?

And also what is the suggested method of including client libs, either create a clientlib specific to the component and load only for that component or include all the CSS and JS at a common clientlib and use it across?


Solution

  • No, the clientlib is only included once for a category.

    This is by design as the HTL (and respective JSP tag) are evaluated during runtime and the processor keeps a map of categories that have already been included and does not include them again.