Tags

,

When MVC 4 was released one of the features that caught my attention was bundling and minification, what does this mean you may ask.

Well Bundling means combining multiple files into one file, i.e. you can create one bundle will all your javascript files and one css bundle containing all your css files.

Minification  will optimize your scripts and css files by removing white spaces and shortening variable names.

The benefit in this is that your pages will make one request for scripts and one for the css files as opposed to a request for each of the required files. 

You do all this in the BundleConfig.cs in the App_Start folder.

That is all you need to do to help speed up your site’s page loads.

What happens when you have done all this but when you watch your production site with a tool like fiddler or IE Devtools and see that requests for each if your files are issued ? Well the answer is simple debug=true yes remember you had enable it to debud your site in dev and now it has come back to haunt you !!! Go ahead and set it to false then all the magic happens.

You can still override this setting in your BundleConfig file by doing the following:

BundleTable.EnableOptimizations = true; 

Hope you will find useful as I have,

Enjoy