Leiste mit Community-Erfolgen erweitern.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

Diese Konversation wurde aufgrund von Inaktivität geschlossen. Bitte erstellen Sie einen neuen Post.

GELÖST

Import Clientlibs

Avatar

Level 1

I'm new working with AEM and faced a situation on WKND Tutorial that couldn't figure out how it happens.

 

When we want to import some clientlibs, many tutorials on onternet explains that is needed to add some code, for example, on customheaderlibs.html file of page component like:

<sly data-sly-use.clientlibs="${'com.adobe.cq.wcm.core.components.models.ClientLibraries' @ categories='wknd.site'}">
</sly>

However, on aem-guide-wknd project on Github, there is no such code anywhere, but the clientlibs are still loaded. How is it possible?

 

Besides that, if I create a new page from the empty-page template, no clientlibs are loaded.

 

What are the others forms of importing clientlibs?

1 Akzeptierte Lösung

Avatar

Korrekte Antwort von
Community Advisor

Hi @mmouraam 

 

You can add client libs

  1. At the component level: using the below code, you include both CSS and js (all)
    1. <sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html">
      <sly data-sly-call="${clientlib.all @ categories=''}"/>
  2. At template level: Edit template > Page policy
    1. Kiran_Vedantam_0-1670434107439.png

       

  3. At the page level
    1. At head.html, include css
      1. <sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html">
        <sly data-sly-call="${clientlib.css @ categories=''}"/>
    2. At footer.html: Include js
      1. <sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html">
        <sly data-sly-call="${clientlib.js @ categories=''}"/>

Lösung in ursprünglichem Beitrag anzeigen

1 Antwort

Avatar

Korrekte Antwort von
Community Advisor

Hi @mmouraam 

 

You can add client libs

  1. At the component level: using the below code, you include both CSS and js (all)
    1. <sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html">
      <sly data-sly-call="${clientlib.all @ categories=''}"/>
  2. At template level: Edit template > Page policy
    1. Kiran_Vedantam_0-1670434107439.png

       

  3. At the page level
    1. At head.html, include css
      1. <sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html">
        <sly data-sly-call="${clientlib.css @ categories=''}"/>
    2. At footer.html: Include js
      1. <sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html">
        <sly data-sly-call="${clientlib.js @ categories=''}"/>