How to use media, preload, prefetch attribute in clientlibs
Hi,
We are working on improving site performance. We have performed an audit using Google Lighthouse. Our page performance score are low. There are various suggestions to improve the page speed. Some of them are
1. Adding media attribute to header link tag to load device specific CSS rather than loading all.
<link href="other.css" rel="stylesheet" media="(min-width: 40em)">
2. Adding preload, prefetch attribute to header link tag to load JS/CSS upfront.
<link rel="preload" href="style.css" as="style">
<link rel="preload" href="main.js" as="script">
3. Use Async and Defer for loading JS
Could anyone throw some light on how to use such above attributes to increase site performance as suggested by Google and various articles. We have tried with Async and Defer as explained in this article [1]. But I would to know whether "async" will really help us to gain performance since we load the JS already in footer as AEM best practice.
Thanks and Regards,
Ruben Fernando
