Why doesnt the MVC4 bundling bundle Knockout.js?
asp.net-mvc, asp.net-mvc-4, asp.net-optimization
Solution
If you look into your project `Global.asax` file, you should find there something like this:
protected void Application_Start()
{
...
BundleTable.Bundles.RegisterTemplateBundles();
}
Now the `RegisterTemplateBundles` is registering only a predefined subset of scripts:
- jquery-*
- jquery.mobile*
- jquery-ui*
- jquery.unobtrusive*
- jquery.validate*
- MicrosoftAjax.js
- MicrosoftMvc.js
- modernizr*
- AjaxLogin.js
If you want some additional files you could either change `RegisterTemplateBundles` to `EnableDefaultBundles`:
protected void Application_Start()
{
...
BundleTable.Bundles.EnableDefaultBundles();
}
Or create your own custom bundle (you can read more about bundling and minification here). You should also know that `EnableDefaultBundles` has some performance impact.
The `_references.js` file is used by Visual Studio for JavaScript intellisense. You can learn more from following article:
- JavaScript Intellisense in VS11, The _references.js File
Problem
I have downloaded MVC4 and trying to work out how the bundling feature works in a standard project. It would seem that having the bundle: ``` <script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js")"></script> ``` Brings back all the jquery.js files but not the knockout.js files in the included scripts. Why is this? And also what is the _references.js file about and why is the knockout.js file commented out?