Skip to content Skip to sidebar Skip to footer

Add An 'async' Attribute To A JS Include Tag In Asp.net Web Forms

I saw how it can be done in MVC, but for a specific project I'm using Web-Forms. I have <%: System.Web.Optimization

Solution 1:

You can use RenderFormat to achieve this:

 <%: System.Web.Optimization.Scripts.RenderFormat ("<script src='{0}' async ></script>", "~/file.js") %>

Renders as: <script src="/file.js" async=""></script>


Solution 2:

This method would should the magic:

 <script src='<%: System.Web.Optimization.Scripts.Render("~/file.js") %>' async> </script>

I extract from:

Bundling and Minification


Post a Comment for "Add An 'async' Attribute To A JS Include Tag In Asp.net Web Forms"