Closed gouravmakhija18 closed 11 months ago
i've looked a bit into this:
the examples and links above are good pointers - however, they are not strictly related to CSS files. moreover there are additional instructions to optimize loading/prefetch behavior in the browser related to all sorts of files (or even only domain names) to optimize web performance
so, i'm not sure if it makes sense to enhance the "css" HTL template for this. keep in mind that the HTL templates provides are merely a facade to AEM's HtmlLibraryManager which allows to generate js/css from clientlibs. the benefit of the wcm.io HTL scripts compared to the AEM built-in ones is to provide more attributes on the generated markup. but the centerpiece is still the actual code generated by HtmlLibraryManager. we could improve the "css" templates by supporting the attributes which only apply to the css use case, and exclude stuff like dns-prefetch, modulepreload etc. this clearly does not relate to CSS - but that does not seem to be the optimal solution.
btw., i'm not a web performance expert, but are you sure it's still best practices to apply all these hints? the articles you are references are all a couple of years old. and if you look at the new AEM Edge Delivery Service (Franklin) stuff, they achieve 100% pagespeed conformance without all those tricks by a clever CDN-based architecture.
I completely agree with you point @stefanseifert but If we are able to provide only below two options to css file, It will really be very helpful to enhance css files performance.
Only preload/prefetch to css file rest can be taken care by HtmlLibraryManager.
i've implemented a PR with preload/prefetch capability for CSS includes in #4 - can you give it a try?
Hi Team,
We have noticed that same like sightly JS custom attributes, css clientlibs should also need support for custom attribures.
e.g.
E.g. There are some example's for reference as given below
Different "rel" attribute variations
Different "as" attribute variations
Reference link: 1) https://www.debugbear.com/blog/resource-hints-rel-preload-prefetch-preconnect 2) https://web.dev/preload-critical-assets/ 3) https://medium.com/reloading/preload-prefetch-and-priorities-in-chrome-776165961bbf