Duha
Duha

Reputation: 829

Jquery validation bundle when use minification version

In the MVC there is RegisterBundles class that we register bundles on it

there is bundle for jquery validation :

     bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.validate.*"));

jquery.validate.* mean that load

 jquery.validate.js and jquery.validate.unobtrusive.js

I start my application in debug mode and release mode and I notes it load jquery.validate.js and jquery.validate.unobtrusive.js

my question how to load minification version in the release mode jquery.validate.min.js and jquery.validate.unobtrusive.min.js

and why the bundle is not from the first

 bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                        "~/Scripts/jquery.validate.min.js",
 "~/Scripts/jquery.validate.unobtrusive.min.js"));

Upvotes: 0

Views: 982

Answers (1)

user1672994
user1672994

Reputation: 10849

You can enable minification even if you add non-minified version of js/css by adding

BundleTable.EnableOptimizations = true;

in your RegisterBundles method (BundleConfig class in the App_Start folder).

check this for more info

You could also enable it through web.config:

<system.web>
    <compilation debug="false" />
</system.web>

Since in release mode the debug attribute will be set as false by transformation script so I would recommend that enable the optimization by this attribute.

You can check if transformation web.Release.config is not removing the debug attribute then you can update it

 <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
 </system.web>

Upvotes: 1

Related Questions