Hide JavaScript Code

Question:

I have been trying for a while to find out if there is any way to hide the direct access JavaScript source code. Is there any way to do this?

Answer:

Diogo, the most you can do is hinder anyone who wants to see the source code but will never be able to hide it in its entirety.

You can make this code:

var a = "Hello World!";
function MsgBox(msg){
    alert(msg+"\n"+a);
}
MsgBox("OK");

appear like this:

var _0x8e48 = ["\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21", "\x0A", "\x4F\x4B"];
var a = _0x8e48[0];

function MsgBox(_0xab5dx3) {
    alert(_0xab5dx3 + _0x8e48[1] + a);
};
MsgBox(_0x8e48[2]);

or only

var a = "Hello World!";
function B(c){
    alert(c+"\n"+a);
}
B("OK");

But the user can always find the code and decipher it. If the browser can use it, the user can see it and try to decipher it.

Scroll to Top