2

I saw how it can be done in MVC, but for a specific project I'm using Web-Forms.

I have

<asp:PlaceHolder ID="PlaceHolder1" runat="server">
    <%: System.Web.Optimization.Scripts.Render("~/file.js") %>
</asp:PlaceHolder>

which generates the html:

<script src="/file.js?v=5jui8vHEj5_iAkaGiAccPPb2LcsdK1jQ1"></script>

I wish to add the sync attribute to the above tag.

I'd appreciate some guidance. Thanks.

2 Answers 2

5

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>

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I couldnt find RenderFormat until I realized it's only available in v. 1.1.0 of Web.Optimization
0

This method would should the magic:

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

I extract from:

Bundling and Minification

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.