VS 2012 bundles to use or not to use, that's the question!

2

I'm starting in VS 2012 and between changes appeared bundles .

I have some doubts:

1 - Is it worth using this approach? Why?

2 - The bundles should even be within the ScriptManager tag

3 - Can I continue referencing the .css and .js of the old form?

    
asked by anonymous 23.12.2014 / 14:06

1 answer

3
  

1 - Is it worth using this approach? Why?

When we talk about optimizing websites, we need to take care of every detail that can slow down processing or traffic. Using Bundle allows you to group multiple files into one.

This grouping brings a number of benefits to the economy of bytes , and provides a very efficient way to organize the project.

  

2 - The same bundles stay within the ScriptManager tag

No. You can use the BundleConfig class located in the App_Start folder and add / declare the files you are going to use, for example:

using System.Web.Optimization;

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        ...

        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
            "~/Scripts/modernizr-*"));

        ...
    }
}

Register the Bundle in the Application_Start method:

void Application_Start(object sender, EventArgs e)
{
    BundleConfig.RegisterBundles(BundleTable.Bundles);
    AuthConfig.RegisterOpenAuth();
}

And add the reference on the page like this:

<asp:PlaceHolder runat="server">        
     <%: Scripts.Render("~/bundles/modernizr") %>
</asp:PlaceHolder>
  

3 - Can I continue referencing .css and .js in the old way?

Yes.

References ):

23.12.2014 / 15:06