Is it possible to hide or scramble/obfuscate the javascript code of a webpage?

后端 未结 9 1152
情深已故
情深已故 2020-12-10 15:38

I understand that client side code must be readable from the browser but I wonder (since there are too many things that I ignore) if there are ways to obfuscate to code to t

相关标签:
9条回答
  • 2020-12-10 16:03

    It is possible to use following tools:

    • YUI Compressor - requires Java - very good compressor

    • Packer - creates the most confusing, and smallest code, but scripts don't run as fast as YUI - this can be used online though. Select 'Base62 encode' for maximum effect.

    • The Dojo Compressor I've never used this one, but it's on the top-list. It also requires Java.

    • JSMIN By Douglas Crockford, this one has a very simple algorythm, but it is still good. Meant to be used in combination with JSLint.

    0 讨论(0)
  • 2020-12-10 16:07

    It is good practice to minify your JS with a tool such as YUI Compressor. I would not obfuscate it unless you have a specific need to do this. There are plenty of online obfuscators such as this one

    See this article: http://developer.yahoo.net/blog/archives/2007/07/high_performanc_8.html

    0 讨论(0)
  • 2020-12-10 16:07

    Check this out.

    Other than min'ing it, I don't think you can really hide js. It all goes the user's browser and there are plenty of ways of seeing it once its there.

    0 讨论(0)
  • 2020-12-10 16:09

    No obfuscation is going to keep your code truly secure and it might just give you the false illusion of security (cf. security by obscurity).

    If you do need to keep some portion of your code secret, consider pulling the sensitive portions into a server side script and making (say) AJAX calls to the script. Especially with the advent of JSON, communicating with server-side scripts has never been easier.

    0 讨论(0)
  • 2020-12-10 16:13

    Is there a reason why this won't do the trick for you?

    http://www.javascriptobfuscator.com/

    0 讨论(0)
  • 2020-12-10 16:16

    Do not put any sensitive or personal information in javascript.

    Spend your time on keeping your data on the server secure.

    0 讨论(0)
提交回复
热议问题