Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net bundling not using the .min files

According to documentation in release mode the bundler should use the .min.js file if it exists. I am adding angular the following way:

bundles.Add(new ScriptBundle(Bundles.Scripts).Include(
                        "~/Content/Scripts/angular.js"));

I have angular.js and angular.min.js in the same folder. So according to what I understand the bundler should just use the angular.min.js and do not do anything itself. But when I check the result in the http response, it's different. It's also minified, but all the names are different:

What I get in the browser:

(function(n,t,i){"use strict";function v(n)

Angular.min.js

(function(P,X,u){'use strict';function M(b)

Can someone explain why this is happening? Does the bundler just ignore the .min file or it minifies again .min.js?

P.S. I have tried to delete the angular.js file and I get an empty result after that, so it seems the bundler does not care at all that angular.min.js exist.

like image 484
Ilya Chernomordik Avatar asked Mar 12 '15 09:03

Ilya Chernomordik


People also ask

How do you override the bundling setting of web config?

Controlling Bundling and Minification To enable bundling and minification, set the debug value to "false". You can override the Web. config setting with the EnableOptimizations property on the BundleTable class.

What is difference between bundling and minification?

Bundling is one of the features of MVC. By implementing this, we can improve performance request load time. Minification is the process of removing unnecessary data without changing its functionality such as removing white spaces, comments, converting the large variable names to small, etc.

What are the different ways for bundling and minification in asp net core?

Bundling and minification are two techniques you can use in ASP.NET to improve page load performance for your web application. Bundling combines multiple files into a single file. Minification performs a variety of different code optimizations to scripts and CSS, which results in smaller payloads.

Can we use bundling and minification with ASP NET web forms like MVC?

To optimize the performance of an application I found that bundling and minification can significantly improve the performance. It can be applied on MVC as well as in ASP.NET web forms.


1 Answers

It seems that in case of a ScriptBundle the library does not do what it should and tries to minify any file. I changed it to just Bundle and that seems to make the trick and load the preminified versions.

Found the answer here: Style bundling for MVC4 not using min files

like image 65
Ilya Chernomordik Avatar answered Sep 28 '22 02:09

Ilya Chernomordik