问题
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!
回答1:
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/
回答2:
You can call out to Google's Closure Compiler from .NET, here's an example:
- http://madskristensen.net/post/Use-Googles-Closure-Compiler-in-C.aspx
Or there's a .NET port of the YUI Compressor:
- http://www.codeplex.com/YUICompressor
回答3:
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.
回答4:
Maybe you can try JS cruncher or stunnix
回答5:
You could take a look at Ajax Minifier which was recently released from Microsoft and which they use internally.
来源:https://stackoverflow.com/questions/1880445/net-component-for-javascript-obfuscation