views:

210

answers:

5

Are there any .Net components for obfuscating JavaScript? I'm generating JavaScript dynamically & emitting via ClientScript.RegisterClientScriptBlock. I'd like to make it more difficult for others to view and modify that script.

Caveats:

  • Yes, I know that JavaScript obfuscation will merely inconvenience a serious developer.
  • I do intend to add (non-obfuscated) copyright notices.
  • My C# program that generates the JavaScript is my real value-add. That source won't be available to viewers. Nevertheless, I'd like to obscure the functions and data that it creates.

Thanks!

A: 

Maybe you can try JS cruncher or stunnix

NM
I'm not seeing where either of these can be invoked programatically from a .Net program. Are these GUI-only?
Mark Maslar
+2  A: 

Try to use the YUI Compressor for .Net. It does not obfuscate, but it do compress at least. You use it as a dll.

http://yuicompressor.codeplex.com/

Johan Wikström
+4  A: 

You can call out to Google's Closure Compiler from .NET, here's an example:

Or there's a .NET port of the YUI Compressor:

cxfx
Thanks for two strong choices!
Mark Maslar
A: 

You could take a look at Ajax Minifier which was recently released from Microsoft and which they use internally.

Darin Dimitrov
Mark Maslar
A: 

The Ajax Minifier mentioned above by Darin Dimitrov has been updated to include obfuscation as well as minification functionalities. It is also designed to work with your build and release process.

Steve Costello