Expand my Community achievements bar.

SOLVED

Clientlib - CSS includes

Avatar

Level 1

Is it possible to use lazyload css using clientlib. In general, there are multiple ways like using aync, media as "dummy" value, prefetch etc., but I am not sure if clientlibs support anyone of these. Please suggest.

1 Accepted Solution

Avatar

Correct answer by
Level 10

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 ...

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

View solution in original post

5 Replies

Avatar

Level 10

From all my experience with CSS and Clientlibs - the CSS styles are picked up when the page loads.

Avatar

Level 1

I meant lazyloading the stylesheet using async, media or prefetch attribute.

Avatar

Level 10

I do not think so -- read best practices with clientlibs -- Using Client-Side Libraries

Avatar

Level 10

A workaround is to load CSS in this manner is implement a solution like you would in a non-AEM web app - javascript - Lazy load of css file - Stack Overflow

I have never tried this - but AEM is a web app and you can still use JS, etc.

Avatar

Correct answer by
Level 10

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 ...

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