Search code examples
asp.net-mvc-4bundlerminify

Bundle vs Minification,Which one is the best


I would like to know about which one of the following way is better.

Bundle the css files and then use :

 bundles.Add(new StyleBundle("~/BootStrap/css").Include(
                        "~/BootStrap/css/bootstrap.css",
                        "~/BootStrap/css/bootstrap-responsive.css"));

OR

Use *.min file directly is as below :

<link href="~/BootStrap/css/bootstrap.min.css" rel="stylesheet" />
<link href="~/BootStrap/css/bootstrap-responsive.min.css" rel="stylesheet" />

I would expect the explanation for performance wise and also as best practices.


Solution

  • Bundling is better because it not only minifies the included files but it packages them together in one resource which translates to one request to the server instead of multiple requests, one for each file.

    In terms of best practice, using Bundling is part of the MVC convention so I would consider that approach to be best practice.