Is it possible to defer or async JS in ClientLibs (AEM 6.1, using JSP)? | Community
Skip to main content
theo_nicolaou
Level 2
Feb 7, 2017 3:48 PM UTC

Is it possible to defer or async JS in ClientLibs (AEM 6.1, using JSP)?

Hi,

Is it possible to defer or call ClientLibs asynchronously in AEM 6.1? So, something like: <cq:includeClientLib js="cq.jquery" async /> or <cq:includeClientLib js="cq.jquery" defer /> ? I have found examples using Sightly in AEM 6.2 but no luck finding examples using JSP's.

Any help appreciated.

Thanks

Theo

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

5 replies

edubey
Level 10
Dec 7, 2017 5:23 AM UTC

If you want this feature from OOTB AEM? - Not supported

But you can follow approach mentioned here for these attributes

GitHub - nateyolles/aem-clientlib-async: Create AEM clientlibs that can output 'async', 'defer' and 'onload' attributes …

Translate
smacdonald2008
Level 10
Feb 7, 2017 4:08 PM UTC

No - its loaded when the script that contains the clientlib is loaded. There is no OOTB setting that delays loading a clientlib. 

Now you can do it with JS itself -- see 

http://stackoverflow.com/questions/9611714/delay-script-loading

Hope this helps. 

Translate
theo_nicolaou
Level 2
Feb 17, 2017 12:26 PM UTC

Hi,

Are there any plans in future AEM versions to allow this? I have seen that you can do it with Sightly in AEM 6.2 but we are using JSP's

Thanks

Theo

Translate
Level 8
Feb 17, 2017 3:13 PM UTC

I don't believe Adobe is putting any attention on improving support for JSP beyond what's already in place.  Sightly is the new standard so it may be worth implementing the component you need this functionality in with Sightly rather than JSP.

Translate