admin管理员组

文章数量:1410717

I am doing some R&D to define all the technologies involved for the developement of a multi tier application that has html5 as browser frontend.

Now I plan to write all the client in html5 css js, having a middle tier my "real" code is anyway safely at server side, anyway for different reasons there could be a reason to hide the javascript in my web pages.

Minifying it is a way to make it less readable, but is there a simple way to "hide sources"?

The js files will typically be on webfarm,but in same cases there will be an enterprise installation, and this is why i am invesetigating a way to "hide the code".

Thanks.

I am doing some R&D to define all the technologies involved for the developement of a multi tier application that has html5 as browser frontend.

Now I plan to write all the client in html5 css js, having a middle tier my "real" code is anyway safely at server side, anyway for different reasons there could be a reason to hide the javascript in my web pages.

Minifying it is a way to make it less readable, but is there a simple way to "hide sources"?

The js files will typically be on webfarm,but in same cases there will be an enterprise installation, and this is why i am invesetigating a way to "hide the code".

Thanks.

Share Improve this question edited Feb 11, 2013 at 13:30 UnDiUdin asked Feb 11, 2013 at 11:38 UnDiUdinUnDiUdin 15.4k40 gold badges161 silver badges258 bronze badges 1
  • 2 possible dublicate how-can-i-obfuscate-javascript – vault Commented Feb 11, 2013 at 11:51
Add a ment  | 

3 Answers 3

Reset to default 5

No, you cannot hide JS source code. If some one wants to take a peek at your JS source they will be able to.

Minification + Obfuscation are things you can do however. Note that these techniques don't protect your source, they only make it difficult to read through your source.

You cannot hide your JS. It will always be visible as long as it is downloaded from your server.

You can use some techniques to make it harder to someone to read your code. These include:

  1. minify and obfuscate (like you pointed out). Using agreesive mode in googleClosure makes the code pretty hard to read.
  2. interpolate client side code with server side.
  3. Getting part of your client side code with AJAX

This only makes "reverse engeneering" harder, not impossible, specially if someone is patient enough to follow the breadcrumbs.


UPDATE: There is an alternative way to "hide" your code. In browsers that support extensions, you can develop an extension with most of your app core funcionalities and use JS to interact with the code. Most browsers support extensions with external dlls. However, this will "force" your users to download your extension to use your webapp which might not be a good idea.

Minifying JavaScript does not in any way hide it, any developer would be able to reformat it in seconds.

By definition, there is no way to hide your JavaScript. Any code that is available for the browser to execute is available for the user to read.

本文标签: minified JavaScript is the only way to protect the source codeStack Overflow