Any Javascript that you write and put on the Internet can be stolen easily by
viewing the HTML source. So, the next best thing to hiding your code is to scramble
it. This Javascript scrambler will take your original Javascript code and make
it incomprehensible by taking out comments, removing spaces, and changing
function and variable names, which also makes it smaller.
Backup your Javascript so that you always have an unscrambled copy.
Cut and paste your Javascript code into the first box.
Test the code for errors. In particular, errors with quotes will cause problems in the scrambled result.
Optionally, type any common variable or function names in the second box, separated by spaces.
Press Scramble. Your scrambled code will appear in the third box.
Test the resulting code for errors. If there are, see the notes below.
Copy and paste the scrambled Javascript back into your web page.
Notes
If your code does not work after scrambling, it is probably because of errors in the original
code (especially to do with quoting) or misuse of the replace box.
You should use the replace box to scramble long and informative variable and function names,
which will be replaced by short nonsense names. For instance, for the shopping basket
program, I used "createCountry getBasket shipping ...". If you scramble
a system function, like subString or a function you call from a form, like
checkForm, your code won't work. This also works for parts of variable
and function names, and the window and document object
are scrambled automatically.
Thanks
Thanks to Sergey Kravchuk for pointing out a way to make sure the
random variable names are not reused, and for his suggestion to extract the function and variable
names automatically from the script (6 August 2004).