1

These files are automatically bundled in a MVC project. I created a new MVC test project in VS 2013 and verified the ones listed below, not the ones added explicity in the BundleConfig, were included in the bundles automatically before the ones that are listed in the bundles.Add() methods.

Setting a break point on the first line of the BundleConfig's RegisterBundles() method shows them in the file order before the other explicitly listed files are added to the bundles. Oddly, the count of bundles is 0, but there are 7 listed in the file order. This also supports the fact that they are added by Visual Studio "behind the scenes" because the files are in there before the ones being added in the C# code.

Most of them aren't listed in BundleConfig and don't show up in the Network activity using IE's Developer Tools. It seems like they should show up in the Network traffic though. I would be interested in an explanation about why they don't show up, if anyone knows.

Calling bundles.Clear() in the first line of the method below didn't remove the ones Visual Studio included, even though this is the intent of Clear(). It appears Microsoft decided they shouldn't be cleared.

These probably can't be removed, but I wanted to see if anyone knows how to do it . We don't need all of them in our production application and I want to omit some, if possible.

   public class BundleConfig
{
    // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Clear();

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

        // Use the development version of Modernizr to develop with and learn from. Then, when you're
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
        //bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                 //   "~/Scripts/modernizr-*"));

        bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                  "~/Scripts/bootstrap.js",
                  "~/Scripts/respond.js"));

        bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/site.css"));

    }
}

In bundles before explicitly adding the other files in the C# above:

  • respond.js
  • jszip.min.js
  • reset.css
  • normalize.css
  • modernizr-*
  • dojo.*
  • mootols-core*
  • mootools-*
  • prototype.js
  • protoype-*
  • scriptaculous-*
  • ext.js
  • ext-*

Files listed in Developer Tools which doesn't include most of the ones above:

  • bootstrap.css
  • site.css
  • modernizer-2.6.2.js
  • jquery-1.10.2.js
  • bootstrap.js
  • respond.js
  • You need to call bundle.Clear() after the .Add calls... or just remove those lines and remove the files? – raven Apr 21 '16 at 17:14
  • I want the ones after the Clear(), but not the ones VS makes me use which is why it's in the current location. This was an effort to clear the ones Microsoft decided I need. – user3692334 Apr 21 '16 at 19:08

1 Answers1

1

Those aren't part of your bundles. You are looking at the BundleCollection.FileSetOrderList Property which:

Gets a list that specifies default file orderings to use for files in the registered bundles.

Screenshot from a default project

As you noted, the bundles count is 0. Those files aren't going to be added "behind the scenes" unless you explicitly include them in your bundles. What will happen behind the scene is that those files will be ordered before your own files when bundling occurs. Though, if you need to, you can specify your own ordering as well.

Reordering bundles is part of the bundling/minification functionality. There is more detail, including the code that defines the ordering in this SO question and answer.

Community
  • 1
  • 1
MikeSmithDev
  • 15,731
  • 4
  • 58
  • 89
  • Thanks for your detailed explanation which is correct in it's description of how these work, but doesn't address what I'm trying to do. I want to remove files that are set in the file order list before my files are added. For example, I don't want modernizer in there. It may not be possible to remove the ones inlcuded by the framework like modernizer. – user3692334 Apr 22 '16 at 16:31
  • @user3692334 My point is, it isn't going to add files unless you explicitly add them in a bundle. Perhaps you commented out the bundle (per your code above) but forgot to remove the reference in your _layout.cshtml file? `@Scripts.Render("~/bundles/modernizr")` and so you think it is still there? (it would still be in rendered HTML in debug mode, but would return a 404). If you don't want modernizer in there, then remove it from your bundle and then remove the files. It can't include files if they aren't there. – MikeSmithDev Apr 22 '16 at 16:37
  • VS doesn't make you use anything... It uses what you tell it to use. Like my answers states, those 7 files aren't part of your bundle. It's a list the specifies the file order. – MikeSmithDev Apr 22 '16 at 16:47
  • Ahh..I see what you're saying now. I had a convoluted idea of how the list works. I thought the files were in there since they were in the order list, even though they aren't in the bundles and that's where I got the idea VS was adding them. Thanks for the commitment to getting this through my hard head! – user3692334 Apr 22 '16 at 17:28