Scriptmanager scriptmode (using .debug.js and minified files)

Jul 12, 2011 at 6:00 AM

Hi there,

When dealing with scriptmanager in webforms, it allows for scripts to be loaded as the debug version or released version

<ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" ScriptMode="Inherit">
<asp:ScriptReference path="~/Scripts/woo.js" ScriptMode="inherit"/>

Basically the above has a scriptmode inherit, meaning it will be dependent on compilation:
If debug mode then it will try to load woo.debug.js
If release mode it will try to load woo.js

So if I had woo.debug.js how can I get chirpy to name it's minified version as woo.js?

Any help would be appreciated thanks

Jul 12, 2011 at 11:47 PM

Work item

Feature : Customize minified version name.

Jul 21, 2011 at 4:44 PM

It would be great if they added this and I +1ed the new work item added.

However I worked around this in an odd way by using a chirp.config like this:

<?xml version="1.0"?>

  <!-- Chirpy automatically removes the last '.debug' so this ensures it stays.  
       Also must include 'min' even if it isn't minified to work with ScriptManager automatic debug settings.
  <FileGroup Name="woo.min.debug.debug.js" Minify="False">
    <File Path="woo.js"/>

  <!-- Chirpy automatically adds .min to the end when minifying so the name below really is 'woo.min.js' -->
  <FileGroup Name="woo.js" Minify="True">
    <File Path="woo.js"/>

Saving this XML as "woo.chirp.config", Chirpy will output a "woo.min.debug.js" and "woo.min.js".  Then your script reference points to woo.min.js.  It is odd because the woo.min.debug.js isn't actually minified, but it still works. 

A nice side-effect is that you can combine several js files into a single one by adding more File sections above.

But globally, it would be great to have this functionality built-in.

Aug 9, 2011 at 7:04 PM