how to add CSS Preload attributes in link tag which is added by sightly | Community
Skip to main content
Abhishekty
Level 4
Jan 18, 2022 5:51 AM UTC
Solved

how to add CSS Preload attributes in link tag which is added by sightly

Hi, 

 

Working on Optimize AEM Site Performance

I need to add CSS Preload attributes in the link tag which is added by sightly.

 

 

For ex:

<sly
  data-sly-use.resolver="${'com.myProject.use.ClientlibResolverUse' @ category='myProject.collections.head', mode='js'}">
<link rel="preload" href="${ resolver.getVersionedPath @context='uri' }" as="script">
</sly>

 In above case I have the link file on "headlibs.html" file but in below case how I can add ?

 

<sly data-sly-call="${clientLib.css @ categories='myProject.global'}"></sly>
<sly data-sly-list.libtouse="${footlibs.clientLibsToAdd}">
  <sly data-sly-call="${clientLib.css @ categories=libtouse}"></sly>
</sly>

In this case, the CSS link file will add when our page will render.

 

For above case what will be the best approach to add rel="preload" attribute. 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
milind_bachani
milind_bachaniAccepted solution
Employee
Jan 18, 2022 5:02 PM UTC

Hi @abhishekty ,

I am not sure if we have an OOTB functionality inplace to achieve the same, however you can refer this thread:
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-use-media-preload-prefetch-attribute-in-clientlibs/m-p/258297

which talks about custom implementation to achieve the same, hope it helps.

Thanks

1 reply

milind_bachani
milind_bachaniAccepted solution
Employee
Jan 18, 2022 5:02 PM UTC

Hi @abhishekty ,

I am not sure if we have an OOTB functionality inplace to achieve the same, however you can refer this thread:
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-use-media-preload-prefetch-attribute-in-clientlibs/m-p/258297

which talks about custom implementation to achieve the same, hope it helps.

Thanks

Translate