Adding “defer” attribute to clientLib script tags in AEM 6.1

五迷三道 提交于 2019-12-31 05:50:48

问题


How would I add the defer attribute to our script tags? We get them via the clientLib tag call in our head.html but there's not much out there for AEM and how to easily add the defer tag to our scripts.

<clientlib data-sly-call="${clientLib.all @ categories=['company-libraries']}" data-sly-unwrap/>

Any help is appreciated! Thanks


回答1:


You could use Jens answer: https://github.com/nateyolles/aem-clientlib-async but that one does not play nice with ACS commons versioned clientlib.which is why I made this: https://github.com/ahmed-musallam/aem-clientlib-async




回答2:


As far as I know this does not work out-of-the-box. But there is a project on GitHub exactly for this purpose (async and defer loading).

See: https://github.com/nateyolles/aem-clientlib-async

With that package you then can do:

<meta data-sly-call="${clientLib.js @ categories='your.clientlib', loading='defer'}" data-sly-unwrap></meta>


来源:https://stackoverflow.com/questions/56638165/adding-defer-attribute-to-clientlib-script-tags-in-aem-6-1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!