Bundling & Minification

This is a feature of MVC, to reduce the request load time of scripts by reducing the number of requests(bundling) & also by reducing the size(minification) of assets (such as CSS and JavaScript).


Bundling is a new feature in ASP.NET 4.5 that makes it easy to combine or bundle multiple files into a single file. You can create CSS, JavaScript and other bundles. Fewer files means fewer HTTP requests and that can improve first page load  performance.


Minification performs a variety of different code optimizations to scripts or css, such as removing unnecessary white space and comments and shortening variable names to one character.

Enabling the Bundling & Minification :

Bundling and minification is enabled or disabled by setting the value of the debug attribute in the compilation Element  in the Web.configfile. In the following XML, debug is set to true so bundling and minification is disabled.


<compilation debug=”true” />

<!– Lines removed for clarity. –>


You can override the Web.config setting with the EnableOptimizationsproperty 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;


Note: Unless EnableOptimizations is true or the debug attribute in the compilation element in the Web.config file is set to false, files will not be bundled or minified. Additionally, the .min version of files will not be used,  the full debug versions will be selected. EnableOptimizations  overrides the debug attribute in thecompilation element  in the Web.config file

Bundled minified versions can be referred in javascript files using 

How to get Yes/No buttons instead Ok/Cancel in Javascript confirm box with default focus set to No button ?

Javascript  Confirm dialog box is used to  prompt some message & retrieve some type of user interaction for further use on the webpage. In this process, Lets consider the following scenario.
Before deleting some file, if user need to be confirmed of doing it, confirm box throws a message like..
“Are you sure want to delete this file ? ” With ‘Ok & Cancel’ buttons to retrieve the user’s input.
Some confusion will arise with regard to ‘Cancel’ word. So it would be better if we have “Yes/No” instead of “Ok/Cancel”.
Also, default focus is set to ‘Ok’ button. This would allow ‘user keystroke’ problems.(Unnecessary deletion of the file if user(by mistake) clicks enter key). So it would be better if we have default focus set to “Cancel” (or “no”).
There might be many solutions to solve this problem, but the solution I implemented is
“VB Script- MsgBox” instead of confirm box.

<script type=”text/javascript”>
    var isChoice = 0;  
      function cancelClick()
      txt = “Are you sure want to delete this file ?”;
      caption = “”;// you can give any title
            // some code to delete the file
             return false;         
<script language=”vbscript”>
      Function vbMsg(isTxt,isCaption)
      testVal = MsgBox(isTxt,4+32+256 ,””)
      isChoice = testVal
      End Function

Some Points about VbScript MsgBox  :
The MsgBox function can return one of the following values:

  • 1 = vbOK – OK was clicked , 2 = vbCancel – Cancel was clicked , 3 = vbAbort – Abort was clicked , 4 = vbRetry – Retry was clicked , 5 = vbIgnore – Ignore was clicked , 6 = vbYes – Yes was clicked , 7 = vbNo – No was clicked

Note: The user can press F1 to view the Help topic when both the helpfile and the context parameter are specified.






Required. The message to show in the message box. Maximum length is 1024 characters. You can separate the lines using a carriage return character (Chr(13)), a linefeed character (Chr(10)), or carriage return–linefeed character combination (Chr(13) & Chr(10)) between each line


Optional. A value or a sum of values that specifies the number and type of buttons to display, the icon style to use, the identity of the default button, and the modality of the message box. Default value is 0
  • 0 = vbOKOnly – OK button only
  • 1 = vbOKCancel – OK and Cancel buttons
  • 2 = vbAbortRetryIgnore – Abort, Retry, and Ignore buttons
  • 3 = vbYesNoCancel – Yes, No, and Cancel buttons
  • 4 = vbYesNo – Yes and No buttons
  • 5 = vbRetryCancel – Retry and Cancel buttons
  • 16 = vbCritical – Critical Message icon
  • 32 = vbQuestion – Warning Query icon
  • 48 = vbExclamation – Warning Message icon
  • 64 = vbInformation – Information Message icon
  • 0 = vbDefaultButton1 – First button is default
  • 256 = vbDefaultButton2 – Second button is default
  • 512 = vbDefaultButton3 – Third button is default
  • 768 = vbDefaultButton4 – Fourth button is default
  • 0 = vbApplicationModal – Application modal (the current application will not work until the user responds to the message box)
  • 4096 = vbSystemModal – System modal (all applications wont work until the user responds to the message box)

We can divide the buttons values into four groups: The first group  (0–5) describes the buttons to be displayed in the message box, the second group (16, 32, 48, 64) describes the icon style, the third group (0, 256, 512, 768) indicates which button is the default; and the fourth group (0, 4096) determines the modality of the message box. When adding numbers to create a final value for the buttons parameter, use only one number from each group.


Optional. The title of the message box. Default is the application name


Optional. The name of a Help file to use. Must be used with the context parameter


Optional. The Help context number to the Help topic. Must be used with the helpfile parameter