Back To FAQ

Enable or Disable bundling and minification in MVC

Bundling and minification is enabled or disabled by two ways, either setting the value of the debug attribute in the compilation Element in the Web.config file or setting 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 EnableOptimizations property on the BundleTable class. This overrides 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;