title: Javascript bundle obfuscation and Bundletransformer
body: <p>I was trying to obfuscate the output of our JavaScript bundles on the fly and came across the <a href="http://bundletransformer.codeplex.com/" rel="nofollow">bundletransformer</a> (a bundling extension that uses YUI Compressor), but had no success implementing it! So far by reading the provided <a href="http://bundletransformer.codeplex.com/wikipage?title=Bundle%20Transformer%201.8.9" rel="nofollow">documentation</a> I've written the following code in the RegisterBundles method:</p>
  
  <pre><code>        var nullBuilder = new NullBuilder();           
          var cssTransformer = new CssTransformer();
  
          var yuiSettings = new BundleTransformer.Yui.Configuration.YuiSettings();
          yuiSettings.JsMinifier.ObfuscateJavascript = true;
  
          var jsTransformer = new JsTransformer();
  
          var nullOrderer = new NullOrderer();
  
          var scriptBundle = new CustomScriptBundle("~/jscbundle/").Include(
                        "~/Assets/Scripts/jquery.js",
                        "~/Assets/Scripts/jquery-ui.js");
  
          scriptBundle.Builder = nullBuilder;
          scriptBundle.Orderer = nullOrderer;
  
  
          scriptBundle.Transforms.Add(jsTransformer);
  
          bundles.Add(scriptBundle);
  </code></pre>
  
  <p>and the following code in the web.config :</p>
  
  <pre><code>&lt;bundleTransformer xmlns="http://tempuri.org/BundleTransformer.Configuration.xsd"&gt;
  &lt;core&gt;
    &lt;css&gt;
      &lt;minifiers&gt;
        &lt;add name="NullMinifier" type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core" /&gt;
        &lt;add name="YuiCssMinifier" type="BundleTransformer.Yui.Minifiers.YuiCssMinifier, BundleTransformer.Yui"  /&gt;
      &lt;/minifiers&gt;
      &lt;translators&gt;
        &lt;add name="NullTranslator" type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core" enabled="false" /&gt;
      &lt;/translators&gt;
    &lt;/css&gt;
    &lt;js defaultMinifier="YuiJsMinifier" usePreMinifiedFiles="true"&gt;
      &lt;minifiers&gt;
        &lt;add name="NullMinifier" type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core" /&gt;
        &lt;add name="YuiJsMinifier" type="BundleTransformer.Yui.Minifiers.YuiJsMinifier, BundleTransformer.Yui" /&gt;
      &lt;/minifiers&gt;
      &lt;translators&gt;
        &lt;add name="NullTranslator" type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core" enabled="false" /&gt;
      &lt;/translators&gt;
    &lt;/js&gt;
  &lt;/core&gt;
  &lt;yui&gt;
    &lt;css compressionType="Standard" removeComments="true" lineBreakPosition="-1" /&gt;
    &lt;js compressionType="Standard" obfuscateJavascript="true" preserveAllSemicolons="false" disableOptimizations="false" ignoreEval="false" severity="0" lineBreakPosition="-1" encoding="UTF8" threadCulture="en-us" /&gt;
  &lt;/yui&gt;
  </code></pre>
  
  <p></p>
  
  <p>Judging from the bundle output I can infer that not only it's not obfuscated but the compression is not taking effect at all! I could not find any samples online and tried changing a few settings here and there with no luck! So I'm pretty clueless and any solutions or suggestions would be much appreciated. Thanks in advance!</p>