locked
Can't figure what is minifying my javascript in VS 2012 RRS feed

  • Question

  • User-1415763228 posted

    I started working on an asp.net mvc 3 web application using VS 2012. I notice that some tool is minifying my javascript automatically as I publish the website. But I have no idea what it is that's doing the job for me. 

    I searched the solution for the token "EnableOptimizations", but found none. 

    Any hint? Thanks.

    Wednesday, October 12, 2016 9:18 PM

All replies

  • User2117486576 posted

    There is a Visual Studio extension (probably more than one) that I know of called WebEssentials that will do that.  You might want to look through the installed extension.

    Other tools like grunt has a watcher that will (I think) minify - probably does other things too.

    Wednesday, October 12, 2016 9:27 PM
  • User-1415763228 posted

    Thanks, I thought about that, too and checked installed extensions via tools > Extensions and Updates. There are MS ASP.NET and Web Tools, VS Extensions for Windows Library for Javascript which seem relevant. However, in a test mvc application using the same VS, my javascript files don't get minified while publishing. So, it must be something else. And grunt is nowhere to find in the solution.

    There is a Visual Studio extension (probably more than one) that I know of called WebEssentials that will do that.  You might want to look through the installed extension.

    Other tools like grunt has a watcher that will (I think) minify - probably does other things too.

    Wednesday, October 12, 2016 9:33 PM
  • User-2057865890 posted

    Hi Antonyliu,

    To enable bundling and minification, set the debug value to "false". You can override the Web.config setting with the EnableOptimizations property on the BundleTable class. The following code enables bundling and minification and overrides any setting in the Web.config file.

    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                     "~/Scripts/jquery-{version}.js"));
    
        // Code removed for clarity.
        BundleTable.EnableOptimizations = true;
    }

    reference: https://www.asp.net/mvc/overview/performance/bundling-and-minification 

    Best Regards,

    Chris

    Thursday, October 13, 2016 2:37 AM
  • User-1415763228 posted

    Hi Antonyliu,

    To enable bundling and minification, set the debug value to "false". You can override the Web.config setting with the EnableOptimizations property on the BundleTable class. The following code enables bundling and minification and overrides any setting in the Web.config file.

    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                     "~/Scripts/jquery-{version}.js"));
    
        // Code removed for clarity.
        BundleTable.EnableOptimizations = true;
    }

    reference: https://www.asp.net/mvc/overview/performance/bundling-and-minification 

    Best Regards,

    Chris

    Thanks Chris, I know about that but it is not what is minifying my JavaScript files. 

    Thursday, October 13, 2016 6:00 PM
  • Monday, October 24, 2016 3:25 PM