How to enable bundling and minification in ASP.NET MVC?

Bundling and minification can be enabled or disabled in two ways: either setting the value of the debug attribute in the compilation Element in the Web.config file or setting the enableOptimizations property on the BundleTable class.

In the following example, debug is set to true in web.config to disable bundling and minification.

Example: Disable Bundling & Minification
    <compilation debug="true" />

Also, you can enable or disable bundling and minification by setting the EnableOptimizations property of the BundleTable class. This overrides the web.config settings.

In the following example, EnableOptimizations is set to true to enable bundling and minification.

Example: Enable Bundling & Minification
public static void RegisterBundles(BundleCollection bundles)
    bundles.Add(new ScriptBundle("~/bundles/mysitescripts").Include(

    BundleTable.EnableOptimizations = true;