View Full Version : how protect external javascript

M rosi
07-21-2010, 06:11 AM
I have designed a web site. but I want to protect my external javascript(and css also) from outside people, who steal my javascript.

can anyone tell me a method to hide external javascript(and css) from these knaves...!!!

thank you

07-21-2010, 06:59 AM
You don't. Don't waste your time.

M rosi
07-21-2010, 07:59 AM
Oh! don't!

can't we get some assistance, at least from sever-side languages ?

07-21-2010, 08:31 AM
Nope. If the browser can see it, so can the user. Read this thread.


M rosi
07-21-2010, 08:55 AM
yaa! that's disable right click.
as you said, it can't be hide external javascript from user.

but can it be like this,

instead of hide javascript in the header part, we can hide the code in the body part using echo which is calling the javascript

then, when someone download the page to local computer, it will not work without that part which we hide using echo.

as an example,

instead of

<td width="53%"><div align="center">
<script type="text/javascript">new inter_slide(slides)</script>

can use like this code(this is not working.may be this code is wrong)

<td width="53%"><div align="center">
<?php echo "<script type="text/javascript">"."new inter_slide(slides)"."</script>" ?>

can I achieve my target from like this code?

I tried this several times but I couldn't. so I hope you will help me.

thank you.

07-21-2010, 09:20 AM
Sir, JavaScript is a client-side language. That means the code is loaded into the client's browser's cache, no matter it is a local code, an embedded code or an external code. So that there is no way to hide a client-side code, JavaScript included. Period. You may encrypt it, maybe, on using a cipher algorithm, but the encrypting key is open, as well, so that a good programmer will decipher it, sooner or later. That is all you can do.

07-21-2010, 09:34 AM
You just can obfuscate ... read here


07-21-2010, 10:00 AM
You just can obfuscate ... read here

Yes, but for every obfuscator there is an unobfuscator as well :D

All you can hope is to make the thief's life as harder as possible. But you can not 100% protect your code.

After all, this effort to find a way to hide a code will do nothing but to make your life harder. You will spend your time and nerves for almost nothing.

Think a little bit, M rosi. Who would and could steal your code? Experienced coders, right? Beginners or ordinary people will not be able to understand the code, so that they are out of the discussion. But, on one hand, the experienced coders have no interest to steal your code, because they are experienced, so that they are able to create their own codes. On the other hand, an experienced coder knows that it is harder to modify somebody else's code than to create your own code.

Let's still say that an experienced programmer wants to steal your code. He will steal it by all means, because he is experienced.

It's like the well known paradox: Humans have no chance to defeat some much more technological advanced Aliens: either they will not attack us, as they have superior minds and they learned that war is useless, or they will attack us, but they are superior and they will defeat us. So that the Humans should stop being paranoid about that. :)

My advice: just focus your mind and energy on your code problems and forget about the "how to hide my code?" impossible task. You will save time, money and nerves :)