title: VS2012 - Web Forms - Bundling Confusion
body: <p>I created a new ASP.NET Web Forms Project through Visual Studio 2012.  Unfortunately, the default Site.Master file is very confusing.  (I am posting these questions together because they are very related and reference the same code quite a bit.)</p>
  
  <p>First off, I <em>already understand</em> the <strong>purpose</strong> of bundling and minification, so no need to discuss that.  However I do <em>not</em> understand what is going with the way the scripts are being included in the default master page.</p>
  
  <p><strong>Question 1:</strong>  <br />
  Why is a bundle called "~/bundles/WebFormsJs" being created in the BundleConfig.cs file, and yet in the master page, each of these same individual .js files are being listed out one by one in the ScriptManager? <br /></p>
  
  <p>Inside BundleConfig.cs:</p>
  
  <pre><code>bundles.Add(new ScriptBundle("~/bundles/WebFormsJs").Include(
                "~/Scripts/WebForms/WebForms.js",
                "~/Scripts/WebForms/WebUIValidation.js",
                "~/Scripts/WebForms/MenuStandards.js",
                "~/Scripts/WebForms/Focus.js",
                "~/Scripts/WebForms/GridView.js",
                "~/Scripts/WebForms/DetailsView.js",
                "~/Scripts/WebForms/TreeView.js",
                "~/Scripts/WebForms/WebParts.js"));
  </code></pre>
  
  <p>Inside Site.Master:</p>
  
  <pre><code>&lt;body&gt;
  &lt;form runat="server"&gt;
  &lt;asp:ScriptManager runat="server"&gt;
      &lt;Scripts&gt;
          &lt;%--Framework Scripts--%&gt;
          &lt;asp:ScriptReference Name="MsAjaxBundle" /&gt;
          &lt;asp:ScriptReference Name="jquery" /&gt;
          &lt;asp:ScriptReference Name="jquery.ui.combined" /&gt;
          &lt;asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" /&gt;
          &lt;asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" /&gt;
          &lt;asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" /&gt;
          &lt;asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" /&gt;
          &lt;asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" /&gt;
          &lt;asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" /&gt;
          &lt;asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" /&gt;
          &lt;asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" /&gt;
          &lt;asp:ScriptReference Name="WebFormsBundle" /&gt;
          &lt;%--Site Scripts--%&gt;
  
      &lt;/Scripts&gt;
  &lt;/asp:ScriptManager&gt;
  </code></pre>
  
  <p>As you can see....  each of those same .js files are individually listed in the ScriptManager.  I don't even see a reference to the "WebFormsJs" bundle that was created anywhere outside of BundleConfig.cs.  Why was that bundle ever created if each of these javascript files were going to be referenced individually here in the ScriptManager?</p>
  
  <p><strong>Question 2:</strong>  <br />
  Why is a ScriptManager being used in this way at all?  I was under the impression ScriptManager was required for Microsoft's version of Ajax such as using UpdatePanels.  What is the purpose of using ScriptManager here... just to simply register javascript files?</p>
  
  <p><strong>Question 3:</strong> <br />
  What is the difference in registering javascript files through the ScriptManager versus up at the top of Site.Master where it uses the following approach instead?</p>
  
  <pre><code>&lt;%: Scripts.Render("~/bundles/modernizr") %&gt;
  </code></pre>
  
  <p><strong>Question 4:</strong> <br />
  Inside the ScriptManager I also noticed these:</p>
  
  <pre><code>        &lt;asp:ScriptReference Name="MsAjaxBundle" /&gt;
          &lt;asp:ScriptReference Name="jquery" /&gt;
          &lt;asp:ScriptReference Name="jquery.ui.combined" /&gt;
  </code></pre>
  
  <p>... I can at least recognize "MsAjaxBundle" from BundleConfig.cs, but where are jquery and jquery.ui.combined defined?  I did a search and found a reference to them in packages.config.</p>
  
  <pre><code>&lt;package id="jQuery" version="1.7.1.1" targetFramework="net45" /&gt;
  &lt;package id="jQuery.UI.Combined" version="1.8.20.1" targetFramework="net45" /&gt;
  </code></pre>
  
  <p>But I don't understand what is going on here either.  I thought packages.config was used for NuGet.  Plus... I don't even see a path listed here for the location of these jQuery .js files.  They are just listed here and strangely associated with a particular version of the .NET Framework (4.5 in my case).  Why a javascript resource would be associated with a version of the .NET Framework is beyond me.</p>
  
  <p>Anyway, question 4 is this:  How is the resource "jquery" in the ScriptManager being added/used?  Why don't I see the jQuery .js files being bundled up together in BundleConfig.cs like all the other bundles??</p>
  
  <p><strong>Question 5:</strong>  <br />
  Can I remove the following script reference from Site.Master if I am not planning on using UpdatePanel and those sort of Microsoft Ajax controls?  I am a little confused as to why this is even included here by default.</p>
  
  <pre><code>&lt;asp:ScriptReference Name="MsAjaxBundle" /&gt;
  </code></pre>