global.asax:
var desktopJsBundle = new Bundle("~/desktop-js-bundle", new JsMinify());
desktopJsBundle.AddFile("~/scripts/jquery-1.7.1.min.js");
desktopJsBundle.AddFile("~/scripts/test.js");
BundleTable.Bundles.Add(desktopJsBundle);
layout.cshtml:
<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/desktop-js-bundle")"></script>
If I visit localhost/desktop-js-bundle/, I see similar to the following:
/*! jQuery v1.7.1 jquery.com | jquery.org/license */
function mytest(){alert('test');}(function(a,b){function cy(a){return f............
As you can see, it started with the comment that is found at top of jquery.js file, then there is the content from my test.js file, then back to the content of jquery.js file. Odd behavior. Any thoughts? Thanks!
There is some internal Ordering going on, it is following certain rules, you can override those rules though.
Here is how you specify the exact order of files:
UPDATE
I reread your question and realized that you were surprised to see the jQuery comments on top. This is due to a different reason than internal ordering:
Basically what happens is all comments on top of the files are extracted and merged together and put on top, this is for example for licensing reasons. Often you are not allowed to redistribute a library without a license on top of it and they usually are within the comments. This way the ASP.NET team made sure they are not omitted when minifying/bundling.