Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding jquery and javascript

I'm working on a mvc application (applies to any website though) and was wondering is it ok to leave exposed jquery and javascript in a view? In other words when i run the program and right click and view source I can see all my jquery and javascript. Is that safe and ok? Is there a way to hide all of that so users can't see that? Thanks for any tips.

like image 381
TMan Avatar asked Jul 29 '26 20:07

TMan


2 Answers

There is no way of hiding javascript completely from the user. JavaScript is a client side technology. It executes in the browser. If the browser can execute the script, it can also show it to the user.

You can use JavaScript obfuscator software to make the code harder to read, but you can never hide it completely. See http://www.javascriptobfuscator.com/default.aspx for an online example of this.

JQuery and other libraries are also publicy available so there is no harm in the user being able to access it. There is nothing secret about them.

If you have secrets in the code that you want to protect, you should think about putting the affected code on the server if possible instead of doing the processing on the client.

like image 160
aKzenT Avatar answered Aug 01 '26 10:08

aKzenT


To make it harder for the interested spy to read you can put your scripts inside .js files and obfuscate them. See How can I obfuscate (protect) JavaScript? for more information.

like image 27
halex Avatar answered Aug 01 '26 10:08

halex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!