Should you care? No.
Why? Because there's nothing you can really do about it.
2) You worry that your competitor is going to copy your site. If they do, you can rest assured that you will always be one step ahead of them. More likely, they are going to write their own code and copy the appearance and behavior of your site and nothing can save you from that except for getting stupid software patents, e.g. amazon one-click shopping.
IOW, don't worry. Put a copyright notice asking people to tell you if they use your stuff. If enough people do it, use the fact that you have created a useful library to get credit among geeks, which probably will be beneficial in the long run.
No. Do not try and "protect" a client-side scripting language. Obfuscation doesn't work. Minifying has its uses (but anti-piracy is not one of them)
I would also recommend against minifying your code unless you get thousands of hits per day, where a few extra kilobytes per request will be a noticeable difference (and only do that once you compress all the images you're using correctly, which will save you far more than a few KB, setup caching properly and so on)..
I would recommend putting a comment at the start of all your
.js files and
<script> blocks, with your information (name, website), and a license of some kind. Depending on what the code is, perhaps putting a notice saying "If you use all or part of this code in a project, please let me know about it!" may be far more effective than "Do not use this code for any other purpose, ever!"
You could obfuscate (or at least minify) the code to discourage this (although it's not unstoppable for someone who has the time. For example, the StackOverflow's deobfuscation of the WMD editor (but this was for a good reason!)).
Really any code you put frontend is going to be public and available for all to see/use.
You can't really since it's an interpreted language that is always delivered in source code form. Even obfuscation is not going to help much if the pirate is motivated enough.
(Case-Example: The StackOverflow WMD Editor, which could be - stricly speaking - be seen as Piracy, although I know that Jeff and Dana only had good intentions)
When not in
That said, in general, I'm -1 on obfuscation -- it means, for instance, that legitimate customers are less able to help you figure out their problems, even when they happen to have development skills and a copy of FireBug. You're the original author -- you know the code better than anyone else, and that gives you a competitive advantage over someone who's trying to run a cheap knockoff; further, if any such competitor is actually making real money off something they stole without permission, that opens them up having that money (or, potentially, treble the sum) taken away in a lawsuit; legitimate and serious competition won't go that route, and why worry about the other kind?
The reason we do this, however, is not so much that we do not want anyone to copy parts of our code, but rather to discourage our partners/customers to whom we deliver the code from making modifications directly in "our files" (to avoid troubles when the next update is installed)...
Note: Obfuscation has one disadvantage you should be aware of, though: if you ever need to debug that script code, you yourself will not be able to work with the obfuscated infromation, so this will always involve copying the 'readable' file to the server first.
Slap a license on it which permits use while requiring for example attribution. Maybe with a non-commercial clause like some Creative Commons variants too, if you really must.
If you are worried about determined hardcore hackers stealing your code, sorry, there is nothing you can do. But there are ways to make it inconvenient for casual thiefs. An relatively easy way to do it is to load some parts using
eval() them; this could be disguised as (or included in) something that gets JSON data and uses them to populate the page.