How can I use the script defer attribute for ASP MVC 4 Bundles with Scripts.Render

后端 未结 4 1901
太阳男子
太阳男子 2021-02-01 04:18

I have looked through Google and Stackoverflow and haven\'t found an answer for this. Is there any built in way to make a bundle execute as deffered or does someone know of an e

4条回答
  •  梦毁少年i
    2021-02-01 04:41

    Try upgrading the Web Optimization to version 1.1.0 on Codeplex Site or via Nuget Package

    In version 1.1.0 they included Element Template Strings. So if you want a script tag to contains the defer attribute you can easily do this:

    @Scripts.RenderFormat("","~/bundles/jquery")
    

    and the following markup will be generated:

     
    

提交回复
热议问题