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.
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.
I think it is difficult to say that which one is better. Both have there own pros and cons.
Check this:-
Bundling
Bundling is a new feature in ASP.NET 4.5 that makes it easy to combine or bundle multiple files into a single file. You can create CSS, JavaScript and other bundles. Fewer files means fewer HTTP requests and that can improve first page load performance.
Minification
Minification performs a variety of different code optimizations to scripts or css, such as removing unnecessary white space and comments and shortening variable names to one character.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With