Hi! I'm about to finish my first "real" game with GameQuery and I'd like to post it on my website. So how can I hide my source code? Same question if I want to sell it. Thanks.
The only way I can think of is some sort of obfuscation... some of the minification tools you can find generate a code that is really quite obfuscated (like the closure compiler from google).
What I would do is merge all the javascript code you use on your game together (jquery, gamequery, you game, ...) and then minify it with the closure compiler in advance mode. You really need to minify all the code at once to be sure to minimize the risk of the minification process breaking you code.
Then to add some level of obfuscation you can use this technique that encode you javascript in a PNG but that will require some more work :)
But keep in mind that those are just obstacle to make it a pain in the ass to steal you code but they are not an absolute guaranty.
Thanks for your reply. It's so bad GameQuery doesn't allow me to sell my games ad the client would need the whole to add it to his website. I've read that Flash has a way to handle it. I'll try your solution though. Thanks again, and let me know if you have anything better.
It's the principal matter with web apps, excepting PHP code, everything is readable with some basic development tools included in all of usual browsers.
By the way, I think that web languages are made in the spirit of internet itself... Indeed the principal purpose of web is to share mass information. Hiding code doesn't make any sense in that philosophy.
In my opinion hiding the code in the web context is a evolution that comes with our generation where every content have to be original, unique and secret in order to be able to make profit on it.
If I may, despite it's a bit rude, its quite the same "war" as capitalism and communism (yes a bit hard i said ^^), as open-source and proprietary technology.
I agree with Freezsystem and I think spending to much time on this is counterproductive.
It's a problem that is not gameQuery specific but a pseudo-related problem that I may try to tackle some day (though it's not a priority) is an anti-cheating system for games that publish hi-scores.
The cheating part was my first interrogation about this kind of coding (i mean javascript language) easily readable and changeable for an experimented programmer.
I first think about a method that verify some things, or exchange some variables (like globals variables) with a php script with an ajax request but it seems to be too heavy to works with a thousand game who works in the same time with a refresh rate of 30 requests per seconds...
As others mentioned, this is not something that is game library specific but is in fact language specific. Uglify-js does a pretty good job as a result of its minification process.