8

In MVC3 C# I'm trying the new System.Web.Optimization Bundles JSminify & CssMinify package (part of the .NET 4.5 framework).

I have one main Bundle. On one page in my website, I wish to include a single .js file only for that page. I would like to have it minified like the bundles, but it does not need to be bundled.

How can this be done?

  • Also, is the source and documentation available for this package?
Hao Kung
  • 28,040
  • 6
  • 84
  • 93
jaap
  • 373
  • 6
  • 15

1 Answers1

7

I think you need to add another bundle to it.

For example:

Bundle myJSBundle = new Bundle("~/combined-scripts/custom/my-page", 
                                                               typeof(JsMinify));
myJSBundle.AddFile("~/Scripts/Custom/MyPage.js");

Then in your page:

<script src="@Url.Content("~/combined-scripts/custom/my-page")" 
                                                 type="text/javascript"></script>

Reference: - http://www.dotnetexpertguide.com/2011/12/bundling-and-minification-aspnet-mvc4.html

More readings:

Meligy
  • 35,654
  • 11
  • 85
  • 109
  • 2
    This is correct. I wrote about that here: http://jclaes.blogspot.com/2012/02/aspnet-mvc4-bundling-in-aspnet-mvc3.html – JefClaes Feb 25 '12 at 20:02