Let's suppose I have these two script bundles configured:
bundles.Add(new ScriptBundle("~/Scripts/Bootstrap").Include(
"~/Content/Scripts/jQuery/jquery-2.1.1.js",
"~/Content/Scripts/Bootstrap/bootstrap.js"));
bundles.Add(new ScriptBundle("~/Scripts/jQuery").Include(
"~/Content/Scripts/jQuery/jquery-2.1.1.js"));
As you can see, ~/Scripts/Boostrap uses a jQuery JavaScript file and a Bootstrap one. This is because the Bootstrap one requires jQuery to work.
On the other hand, ~/Scripts/jQuery is composed of only the jQuery file.
I want to have two bundles in case a view only needs jQuery and not Bootstrap.
However, I am replicating code here, I am defining the jQuery JavaScript file path twice.
Is there a way to tell the ~/Scripts/Boostrap bundle to use or "inject" another bundle?
Something like this:
bundles.Add(new ScriptBundle("~/Scripts/Bootstrap").UseBundle("~/Scripts/jQuery").Include(
"~/Content/Scripts/Bootstrap/bootstrap.js"));
I want to have two bundles in case a view only needs jQuery and not Bootstrapsounds perfectly logical from a world where we are uninformed about caching. As soon as caching is involved, the idea of bundles per view is actually worse in performance than multiple scripts per view beyond the first request (more often than not).