Bundling and Minification in Asp.net MVC

We can do bundling and minification to improve request load time.
Bundling and minification improves load time by reducing the number of requests to the server and reducing the size of requested assets (such as CSS and JavaScript.)


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, basically help to improve request load performance.


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


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. The following code enables bundling and minification and overrides any setting in the Web.config file.

In MVC we can create bundle in bundleconfig files as shown in code.

similarly we can use JS bundle as well.
and on the view page or shared view we can directly called with bundle name.


Hope this help you in minification and bundling.