Search code examples
cssasynchronousrazorasp.net-mvc-5bundles

Asynchronious CSS load with MVC5 Bundles


I was reading about asynchronous CSS loading here and I was wondering if it is possible to use that kind of behaviour in MVC5 bundles.

What I want to achieve is multiple bundled CSS files downloaded in a non-blocking way (meaning faster loading time of my page)


Solution

  • There's a method on the Styles helper where you can set your own tag format.

    @Styles.RenderFormat("<link href=\"{0}\" rel=\"preload\" as=\"style\"/>",
                         "~/Path/To/My/Bundle")