Javascript js file encoding [duplicate]
Possible Duplicate:
How can I obfuscate JavaScript?
Hi I need to Encode my js file to upload my host when save my page i dont want user see my js and my javascript code any body idea
you can't encrypt or encode your JS as the browser needs to run it.
The only thing you can do is to minify it, so it gets hard do read. But someone with the right tools and time will be able to reconstruct the code.
Hi there is no way to encript a js page, but there are a few tricks you can do to obscure te code.
First, you obscure the code, by changing the variable to value that do not make much sense. If you do that, keep a original copy. ie.:
var firstname = 'Paul'; // change it to var fn = 'Paul'; or var 00110011 = 'Paul';
function returnFirstname(){} // change it for rtnFN011010(){}
In order to do that, you would need to program a script that does it for you.
Second, minify your code : http://fmarcia.info/jsmin/test.html
Good luck
The is no definitive way to do this, the best you can do is minify your js file. Search Google for "JavaScript Minify", there are plenty of tools out there...
精彩评论