1

From my understanding, JavaScript code, because it is client-side, is not hidden to the client, and is hence de facto open source.

I am aware of "code obfuscation", but according to Wikipedia, "At best, obfuscation merely makes it time-consuming, but not impossible, to reverse engineer a program."

Is it possible to truly hide your JavaScript code, to keep it closed source?

7
  • Execute it only on the server? Commented Jul 29, 2011 at 1:22
  • Really, @Tomalak? What about node.js? (cf nodejs.org) -- it can be used as a server-side language today as well, there is support and a decent ecosystem; Heroku now runs node apps, etc. Commented Jul 29, 2011 at 1:24
  • @Joe: In the vast majority of cases, Javascript is used for user interaction. When you have an existing application that does this, "execute it only on the server" is far from a useful suggestion. Commented Jul 29, 2011 at 1:25
  • Even though closed-source server-side JavaScript is definitely reasonable/possible, it is clear OP is most likely concerned with client-side only. Just pointing out JS is potentially more than that. Commented Jul 29, 2011 at 1:27
  • 1
    Even if you use JS server-side that doesn't mean it is or isn't "open source", as explained in the accepted answer. (Another nitpick.) Commented Jul 29, 2011 at 1:58

3 Answers 3

7

Open-source doesn't mean "I can see the source". It means, loosely, "the licence allows me to re-distribute this source and do what I like with it [disclaimer: see licence terms]". So your terminology is in error.

Ultimately, if you are delivering your Javascript to a web browser on your user's PC, the user has as much access to it as does his PC. You can't prohibit that. You can mitigate it slightly with obfuscation, but the Wikipedia quote is absolutely correct.

Just provide quality software and move on.

Sign up to request clarification or add additional context in comments.

2 Comments

In an IT context, "open" means able to be accessed without special licence, as in "open standards". It does not necessarily mean you can redistribute the code, re-publish or even use it (regardless of the impracticalities of preventing people doing that). There are licences that support "open source", that is, allow access the code without restriction, but users are still restricted by the terms and conditions of the licence. Even if there is no licence, the code is covered by copyright (in most jurisdictions) so you can't just do what you want with it without express permission.
@RobG: It's like you completely ignored the "disclaimer" part.
1

No it is not possible, but licensing can deter theft.

Comments

0

You can't hide your front-end javascript from the user (unless you're talking about server side javascript such as node.js, but that's a different topic alltogether), but if your goal is to hide it as much as possible via obfuscation, javascript compression isn't a bad way to go about it. Google has a really good javascript compressor that will make you code all but impossible to reverse engineer. Additionally, it also makes your code take up less space, which means it will load faster.

http://code.google.com/speed/articles/compressing-javascript.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.