Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make my JavaScript code unusable by anyone else? [closed]

Heh, that's something that many plugin authors do without needing help, isn't it? :) Here's the rub -- I'm coding a jQuery plugin which I have the intent to sell. I want to provide a live demo of it; of course, I don't want anyone just using the demo code.

I know it's dumb, and it certainly doesn't bring any good karma, but what are some naughty things I can do in the demo script that would make life reasonably difficult for anyone trying to use it? Setting undefined = true comes to mind, as well as overriding jQuery methods. Any suggestions beyond that?

like image 508
avramov Avatar asked Mar 21 '26 18:03

avramov


2 Answers

I like Diodeus's idea of a video (or a screencast, etc.).

But if you absolutely, positively want an interactive demo, take jQuery, your plugin, and your demo code, put all three together, and throw the Closure Compiler at it (with advanced optimizations if you can get that to work with jQuery; with simple optimizations otherwise). The Closure Compiler is a lot more than just a minifier; it actually re-writes your code, inlining functions (even in simple mode), changing identifier names, etc. If all the code is compiled together, you don't have to tell it to "export" any symbols, it can have a renaming, inlining frenzy. :-) It will conflate the three parts (jQuery, plug-in, and demo) such that it'll be far more work than it's worth to unravel them.

like image 158
T.J. Crowder Avatar answered Mar 24 '26 06:03

T.J. Crowder


The JavaScript environment, by its very nature, is insecure. Other than minifying the code, there's nothing you can really do. If the browser can see it, the user can see it. It's the same argument of trying to prevent people from stealing your images.

If you want to make a demo, make a video of it.

like image 41
Diodeus - James MacFarlane Avatar answered Mar 24 '26 07:03

Diodeus - James MacFarlane