0

I'm trying to use knockout.js imported from NuGet which includes knockout-3.2.0.js and knockout-3.2.0.debug.js. I add a new bundle like

bundles.Add(new ScriptBundle("~/bundles/knockout").Include(
    "~/Scripts/knockout-{version}.js"));

However when I inspect the webpage, it turns out that the loaded bundle is knockout-3.2.0.debug.js.

I read the following questions

  1. what is {version} in ScriptBundle("~/scripts/jquery-{version}.js")
  2. {version} wildcard in MVC4 Bundle

which seem not to be particularly helpful in answering my question.

2
  • Are other bundles working? Did you do BundleTable.EnableOptimizations = true; Commented Nov 26, 2014 at 4:13
  • I don't enable the optimization. Others' don't have debug version script. Commented Nov 26, 2014 at 4:19

2 Answers 2

2

In Visual Studio you can have several Solution Configurations (it's a dropdown in the button vars under the Visual Studio main menu, by default in the Standard bar). By default, when you create a new project (or solution) you have 2 available configurations: Debug and Release. (You can acces to this also in the Build > Configuration Manager... menu).

When you build your solution or porject (or when you publish it) you must choose one of the configurations:

  • if you choose Debug, the project is compile with debug information, so that you can attach it to VS debugger and associate the running code with your source files. Besides there are some other things that happen, for example tha tthe bundler will use the debug version of JS files, instead of generating the minified bundle. The idea behind this is that, if you use this configuration, it's because you want to debug your code.

  • if you choose Release, the project is compiled without debug information. And the bundles use the normal or minified versions of the script, and each whole bundle is converted in a single, minified file

So, what you need to do is to choose the right configuration. Take into account that this affects both the js bundling, and the creation of assemblies. Sometimes the code in the assemblies can even have better performance because the release version will have some optimizations which are nos applied in the debug version of the assemblies, to allow debugging them.

Sign up to request clarification or add additional context in comments.

Comments

2

It is because you have debug version of JS present in scripts folder.

If you look at other js there no debug file present so It will use jquery.1.7.0.js, but if you copy paste jquery.1.7.0.debug.js then it will choose that.

If you want knockout-3.2.0.js to be use then delete debug version of js.

You can also go to web.config

 <system.web>
    <compilation debug="false" targetFramework="4.0" />
    // set debug="true" or debug="false" 

if you set debug=true then debug version get selected or another version of js is selected if debug is false.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.