Tutorialsteacher

Follow Us

Articles
  • C#
  • C# OOP
  • ASP.NET Core
  • ASP.NET MVC
  • LINQ
  • Inversion of Control (IoC)
  • Web API
  • JavaScript
  • TypeScript
  • jQuery
  • Angular 11
  • Node.js
  • D3.js
  • Sass
  • Python
  • Go lang
  • HTTPS (SSL)
  • Regex
  • SQL
  • SQL Server
  • PostgreSQL
  • MongoDB
Entity Framework Extensions - Boost EF Core 9
  Bulk Insert
  Bulk Delete
  Bulk Update
  Bulk Merge
  • All
  • C#
  • MVC
  • Web API
  • Azure
  • IIS
  • JavaScript
  • Angular
  • Node.js
  • Java
  • Python
  • SQL Server
  • SEO
  • Entrepreneur
  • Productivity

Enable or Disable bundling and minification in 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
<system.web>
    <compilation debug="true" />
</system.web>

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(
            "~/Scripts/MyJavaScriptFile-1.js",
            "~/Scripts/MyJavaScriptFile-2.js",
            "~/Scripts/MyJavaScriptFile-3.js",
            "~/Scripts/MyJavaScriptFile-4.js",
    ));

    BundleTable.EnableOptimizations = true;
}
TUTORIALSTEACHER.COM

TutorialsTeacher.com is your authoritative source for comprehensive technologies tutorials, tailored to guide you through mastering various web and other technologies through a step-by-step approach.

Our content helps you to learn technologies easily and quickly for learners of all levels. By accessing this platform, you acknowledge that you have reviewed and consented to abide by our Terms of Use and Privacy Policy, designed to safeguard your experience and privacy rights.

[email protected]

ABOUT USTERMS OF USEPRIVACY POLICY
copywrite-symbol

2024 TutorialsTeacher.com. (v 1.2) All Rights Reserved.