system.web.optimization

Bundle and minification with html page


I am using asp.net 4.5 Bundling and Minification in my project. I want to use the jscripts bundle in html page. I have tried without success

@Scripts.Render("~/bundles/jquery")

<script src="~/bundles/jquery" type="text/javascript"></script>

@Scripts.RenderFormat("
  <script type=\"text/javascript\" src=\"{0}\"></script>", "~/bundles/jquery")

My question is that is it possible to use jscripts or CSS bundle in html page?


Solution

  • No, you can not use bundles in static HTML pages. The page will just be served as it is.

    If you want to take advantage of bundling and minification you will need to use razor .cshtml views.