The minification is used to reduce the size of CSS and Javascript files to speed up download times. This process is done by removing all of the unnecessary white-space, comments, and any other non-essential content from the files.
This process is done automatically when using a ScriptBundle
or a StyleBundle
object. If you need to disable it, you have to use a basic Bundle
object.
The following code uses preprocessor directives to apply bundling only during releases in order to allow for easier debugging during non-releases (as non-bundled files are typically easier to navigate through) :
public static void RegisterBundles(BundleCollection bundles)
{
#if DEBUG
bundles.Add(new Bundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.js"));
bundles.Add(new Bundle("~/Content/css").Include("~/Content/site.css"));
#else
bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.js"));
bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));
#endif
}