[RESOLVED] Bundling and Minification works in debug mode but in release mode it is not working very urgent

Hi All.

This is an urgent request. I have a unique scenario. I have done bundling and minifcation done. But I see that it is working in the debug mode but not in release mode(please note debug mode is working & release mode is not working). I have ensured that files with .min extensions are not bundled. Also I see that the bundles are actually rendered in the browser (using F12 debugger), but when a call to the method in JS file are made it is throwing an error.

I also ensured that the bundle order is set. I use the below code to set the bundle order

public class AsIsBundleOrderer : IBundleOrderer


       public virtual IEnumerable<FileInfo> OrderFiles(BundleContext context, IEnumerable<FileInfo> files)


       return files;



Enev after all these things the error exist.

My only doubt is the can there be any issue in calling the minified script from ASPX page. Is it changing some function names or any other JavaScript object names.

If this is case how to avoid minification and just use bundeling alone.

Thanks and regards

The difference is this. Let's say you have both jquery-1.9.1.js and jquery-1.9.1.min.js in your scripts folder.

Debug modewill use jquery-1.9.1.js as the source script, and no it won't be minified or bundled, as the whole bundling/minification is disabled in debug mode (though you can override this).

Release modewill use jquery-1.9.1.min.js AND bundle it with other scripts for that bundle. If you only have the one file, jquery-1.9.1.js

, Release mode will use it and minify and bundle it. Debug mode will NOT use .min files. So if you use a wildcard to include all files for a scripts directory, your .min files will not be included.

Debug mode, if you look at the rendered HTML, will reference all script files in the bundle individually. In Release mode, there will only be one script reference (with a querystring for versioning) per bundle.

When using Bundling and Minification in debug mode (when <compilation debug="true" /> is set in your web.config ), undling/minification is disabled.

You can override this and force bundling and minification by adding

BundleTable.EnableOptimizations = true;

. This will make it act like it will in your production environment, where everything is bundled and minified, and the script reference includes that versioning parameter (like you gave) that will force the browser to reload your scripts when anything changes:

public class BundleConfig
    public static void RegisterBundles(BundleCollection bundles)
        //all your bundle code
        BundleTable.EnableOptimizations = true;

Please reference. Hope that's helpful.


Hi Chunyan Yu,

Thanks for your reply. I have tried this and have replicated the error in local machine also. In unbundled state the scripts are working fine where in bundled state the script is not working. I'm using Jquery 1.9.1 and all my scripts are depeneded on that. I have  two bundled created

1) Jqeury, Jquery -UI

2) Application specific script bundles

The Jquery and Jquery UI are included in master page where as the application specific bundles are all put in child pages that inherit from master page.

Even after this I find that the application specific pages are not working. Using f12 developer tools I'm able to see both the Jquery bundle and Application specific bundle getting downloaded. But still I get an error saying Jqeury ($) is invalid.

But the same thing works in google chrome. Are there any suggestions. It is pretty urgent and I'm stuck

Thanks and regards


Hi All,


I have found a solution for the same. It appaears like the .min.js version of Jquery are having some proble. When I did some googling I see that there was some issue @soureMapURL issue in Min.JS. But that was also correct in 1.9.1.min.js. Since I could not find the exact cause. I just removed the min.js and allowed the JsMinifier itself to the jb of minification and that worked like magic.


Thanks and regards


thoughts on "[RESOLVED] Bundling and Minification works in debug mode but in release mode it is not working very urgent"

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>