Bundle vs Minification, which one is the best

I would like to know which of the following methods is better.

Link 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:

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

I would expect an explanation of effectiveness as well as best practices.

+4
source share
3 answers

Linking is better because it not only minimizes the included files, but also combines them into one resource, which translates into one request to the server instead of several requests, one for each file.

From a best practice point of view, using Bundling is part of the MVC agreement, so I would consider this approach the best.

+4
source

I think it's hard to say which one is better. Both have their pros and cons.

Mark this : -

Packaging

Linking is a new feature in ASP.NET 4.5 that makes it easy to merge or merge multiple files into a single file. You can create CSS, JavaScript, and other packages. Fewer files means fewer HTTP requests and this can improve front page load performance.

Minimum

Minimization performs many different code optimizations for scripts or css, for example, removing extra space and comments and reducing variable names to one character.

+1
source

Use packaging with caution.

While it reduces the number of http requests, it makes the browser cache (and proxy cache, CDN cache, and any cache you use) less useful .

Let's say you have scriptA.js and scriptB.js . Some pages use A , some pages use B , some pages use both A and B

There are three different scenarios with the package. Without tying him two.

0
source

Source: https://habr.com/ru/post/1502297/


All Articles