views:

420

answers:

9

I have a lot of customized javascript and layout design, and I want to prevent as best I can people just copying and pasting and then using it for themselves. Is there any practical way to do this, or do I basically just have to be happy my php code does not show? I want to at least make it difficult to copy my site.

EDIT Thanks for all the suggestions +1 to all

+7  A: 

There's no way to prevent people from seeing your source code. There are ways to obfuscate it and make it difficult to reuse, but there's no way to hide it. Also note that obfuscation makes it hard to maintain as well.

Jason
Do any big sites obfuscate? I don't think so right?
Scarface
some sites do, of course. i don't believe it's that widely practiced, however, because it's impossible to completely protect. anyone who really really wants your client side code is going to get it, obfuscated or not.
Jason
Yes a lot of them do, but it is done to save bandwidth and not to protect their intellectual property.
BrianLy
BrianLy: I'm sure it's for both reasons.
Matt
well, they minify, which isn't always the same as obfuscating. i guess PACKing is kind of both, but less obfuscating and more reducing byte transfer.
Jason
@Scarface, some kinds of obfuscation have the side benefit of making the code shorter (by changing identifiers for variables and functions, etc.), so you do see it occasionally on high traffic sites where every byte counts.
Mike Daniels
Thanks a lot guys, I am definitely going to use minify, I think that would be the best thing to do to make code hard to take, and really improve performance as well. Brian suggested a minifier, and it looks good. I used to think I had to delete whitespace and such manually, but this way I can still keep my code intact.
Scarface
Obfuscation doesnt make anything harder to maintain becuase you have access to the original source
James Westgate
true, but after you fix it, you have to re-obfuscate before pushing. not "harder" per se, but more of a PITA.
Jason
+2  A: 

You can use an obfuscator, if you like. It makes the source human-unreadable.

rlb.usa
+3  A: 

You can use an obfuscator for your code which will make site loadable but not readable to the other developers - they will not have an easy way to modify and adapt it.

Vladimir
+8  A: 

All client-side code can be copied. If you're a web designer, your best bet is to just brand yourself well and keep innovating so that clients are more interested in the originator than the imitator.

HaleFx
+10  A: 

If people really want to get access to your source code they can do that fairly easily.

It is possible to slow people down to a limited degree by obfuscating code.

See:

Maintaining obfuscated code is difficult. What you want to do is obfuscate it before deployment so that you can test and debug with the normal version. Debugging problems on a live site can be made a lot more difficult by the obfuscation.

BrianLy
hey sweet, I was looking for a way to minify forever. Thanks a lot.
Scarface
Took a look at the minify one, and it looks like something worth using, even if just to reduce bandwidth. +1
Slokun
I just installed the minify, boy is that key. Thanks a lot for suggesting that, it minifies reducing bandwidth, and makes the code a pain to read. Thanks again.
Scarface
+4  A: 

I use the Google Closure compiler for javascript. This is to reduce download size and remove redundant code but it has the added benefit of making the code much harder to read.

James Westgate
+2  A: 

I have always envied people who sell JavaScript products because their work is always out in the open. I think this is a terrific detergent for anybody who has something to lose, i.e. businesses, commercial web sites, and such. The day Google (or another big search engine) offers the possibility to search in pages' source code, you can start detecting copyright infrigements within minutes.

And even if that search engine option never comes up - it's still possible to find out, very quickly and effortlessly, whether a site uses stolen Javascript.

On the other hand, a minificator used by the person stealing the code would make this much, much harder. So some minification / obfuscation, as suggested in the other answers, is probably a good idea nevertheless.

Pekka
I am going to use the google project minifier, due to its ease of use, thanks for the comment.
Scarface
+5  A: 

Just write crappy code. It won't prevent copying, but it will take away the motivation to do so.

Robert
haha trust me my code is already crappy looking.
Scarface
+3  A: 

By far the most widespread method is to write so bad code that no one in their right mind would want to copy it, it's employed by approx 99% of web sites.

Is it actually a problem to you if someone snatch a piece of your code?

Sure it is a problem if someone the steal the whole site/application, but the only way you can really deal with that anyway is through standard legal means.

eBusiness
that is a good point, I am already seeing to have my work copyrighted when I am finished. Is your copyright still valid if you update your work? Do you have any useful advice as far as legal protection?
Scarface
Under the Berne Convention, copyright applies the moment any creative work (i.e. your software) is created. There are no steps to be taken to make unauthorized copying or derivation an infringing act. To actually pursue an infringer, you may have to go through a registration on the particular version infringed.
Novelocrat
Thanks a lot for the comment, so you are saying to pursue someone, who have to copyright a copy of your site with your government to have a reference version?
Scarface