How to add async to resource file while using @Styles.Render in ASP.NET bundling?

21 views Asked by At

Although I am working in Sitecore application but had implemented ASP.NET bundling for minification of some of the resource files.

My question is can we add async property to a bundled file rendered using @Styles.Render method?

In layout this has been @Styles.Render("~/bundles/css") added and below is the bundle table registration:

enter image description here

Output

enter image description here

What I need is:

<link href="/bundles/css?v=qJHzaYh2DdlW6ioB10YzF1YhQUJqGncz6xM6vUV2sAA1" rel="stylesheet" async/>

Note: I have already tried using @Styles.Url to get the bundled url and adding to the link and marking it async but due to some reasons its not working in given env.

1

There are 1 answers

0
Arjun Arora On

Upon searching, i found pretty straight forward solution:

<link rel="stylesheet" href="@Styles.Url("~/bundles/css")" async>

Output: enter image description here