views:

444

answers:

7

Hello,

I am planning to sell a javascript code that I have written. Given the current state of browsers its quite possible to write complex code. I think I will face a couple of problems/have a couple of questions:

  1. Javascript being client-side can be easily copied as soon as I show someone a demo
  2. Are there any companies selling javascript code? Not dual licensed like ExtJS.
  3. Should I obfuscate my code? Should I hard-code the website on which it will run and pack it etc.?
  4. How do I go about this?

Thank you for your time.

A: 

There are some companies selling js code. How well they do it - don't know.

The only thing you can do to protect your code is to obfuscate it.

Pavels
+1  A: 

Milonic sells some JavaScript components.

Not sure how they protect them, but they have been in business for a long time.

Dana Holt
+2  A: 

There are numerous companies which sell Javascript 'components', and I know at least some of them obfuscate their code. A lot of obfuscators & compressors do some horrendous things with eval and encoded strings... I'd recommend against going down that path.

In my experience, all obfuscated code does is frustrate your honest customers. In many ways it comes down to who you're targetting. If you're making drop-in components, obfuscating things isn't going to be a huge problem. If you're targetting developers, you're going to need to keep your code open imo.

If you choose to obfuscate, the best way for performance and reliability is going to be using a javascript compresser like YUI: http://developer.yahoo.com/yui/compressor/

Andru
+2  A: 

The easiest thing to do to obfuscate it would be to use the Online YUI minifier.

Basically, the effort required to de-obfuscate it, is pretty similar to having to rewrite it. That won't necessarily stop someone from stealing it, but again, it just depends on what kind of market you are in. Most people are honest.

Pretty much all JavaScript is open source by design. Seems that plenty of people are making money in open source. I wouldn't sweat it too much. Sell on the value or the service.

altCognito
+11  A: 

To be honest, with any software, no method of protection is 100% safe from being misused. Think, for example, with even large-scale commercial pieces of software, such as Photoshop, Windows or OS X. All have methods in place to try and prevent people from misusing or pirating their software, and to the average user, this is fine, and prevents people from simply copying their software and distributing it illegally.

However, if people really want to use software illegally, they'll find a way - they may reverse-engineer it, and then create keygens or remove piracy mechanisms completely, for example.

Of course, being a scripting language, applications written using JavaScript is more susceptible to misuse, since, as you pointed out, as the JavaScript runs client-side, anyone can view your JavaScript quite easily. However, for many of your customers, this shouldn't be a problem, and it is quite common nowadays for companies to software of this nature commercially, which use JavaScript as the main method of their implementation.

There may be a few people who try and misuse your software, but as I pointed out above, this occurs in all walks of software development, and all you can do is your best to prevent this from happening. As you suggested, JavaScript obfuscation is a good way to make the source less readable, (but there are some limitations, for example with stripping some legitimate lines of code that the obfuscator believes to be unnecessary), but at the end of the day, you just have to remember that most people are likely to legitimately use your software in the correct manner, and that over-protecting your software will only cause your legitimate users annoyance, to try to deter a small minority of people who are likely to provide a workaround to any mechanisms anyway.

Perspx
+1  A: 

Remember that "stealing" the code is not just about obfuscation, but also about just straight-up copy-pasting it to another site and using it as-is. It would not be unreasonable to include some type of licensing request for the script, perhaps checking the domain the request was sent from against a central server. Of course, then you'd need obfuscation just to keep people from removing the licensing check...

JoshJordan
+5  A: 

Companies that normally sell JavaScript components are really selling support for those components. Guaranteed bug fixes, prompt response to questions, etc.

epascarello