Here, the default MVC5 App BundleConfig:
public class BundleConfig
{
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));
// 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"));
}
}
Wouldn't it be much simpler to have just one bundle, where you will include all the scripts you need? like this:
public class BundleConfig
{
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/scripts").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery.validate*",
"~/Scripts/modernizr-*",
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js"));
}
}
Or, even simpler, like this (in Script folder you only put JS files you need):
public class BundleConfig
{
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/scripts").Include("~/Scripts/*"));
}
}
Wouldn't it be much simpler to have just one bundle, where you will include all the scripts you need?
This might simplify the development process slightly as you do not need to look for corresponding bundle to include. But lets look at this from another perspective.
On asp.net forum the following it is witten:
Bundling and minification are two techniques you can use in ASP.NET 4.5 to improve request load time. Bundling and minification improves load time by reducing the number of requests to the server and reducing the size of requested assets (such as CSS and JavaScript.)
So we do bundling to make things work faster. What if you've created a page with a simple form where no bootstrap.js
is needed. Why would you load it then provided you are interested in speeding everything up?
The best performance option is to have all possible js files combinations you might require in one place in separate bundles. Each page make only one request to get all js it needs. However this way of things is rather difficult to maintain.
So it's up to you to decide which aspect you are interested in.