You may ask yourselves why someone need to hide some script? First – if this is something of your own and you do not want to be stolen, or to hide something from bots for example.
In my case, it all started with hiding my e-mail from bost to prevent spam in my inbox and then evolved to hiding the complete js code. Obfuscating your code is a good solution, but it’s not enough, because, although it is hard, someone could decipher your code.
What I’m actually doing is to delete the contents of my dom script element, so that after the browser evaluates your code, the code disappears.
For example, if your code is this:
you just have to change it to this:
This is a simple hack. In any way, it cannot fully protect your code but it will make it quite a challenge.