tero.co.uk

Javascript Scrambler

Please note that this was written many years ago (2003 or before maybe) and there are now much more reliable ways of obfuscating Javascript code such as the YUI Compressor.

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.

  1. Backup your Javascript so that you always have an unscrambled copy.
  2. Cut and paste your Javascript code into the first box.
  3. Test the code for errors. In particular, errors with quotes will cause problems in the scrambled result.
  4. Optionally, type any common variable or function names in the second box, separated by spaces.
  5. Press Scramble. Your scrambled code will appear in the third box.
  6. Test the resulting code for errors. If there are, see the notes below.
  7. Copy and paste the scrambled Javascript back into your web page.

Your Javascript code
Type variable and function names (or try to find them automatically)
Scrambled code

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). Russian version provided November 2015 by Everycloudtech