Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 548
Sampath Avatar asked Mar 23 '23 10:03

Sampath


2 Answers

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.

like image 100
asymptoticFault Avatar answered Apr 01 '23 11:04

asymptoticFault


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.

like image 27
Rahul Tripathi Avatar answered Apr 01 '23 11:04

Rahul Tripathi