Sunday, May 21, 2017

Can you block direct access to .js file

Tags



Answer is you can still block it, but not 100%.

1) Obfuscate the code YUI Compressor
2) If you have direct access to.htaccess, you can rewrite by preventing access to .js file. http://stackoverflow.com/questions/6335644/how-can-i-block-direct-access-to-my-javascript-files
3) Write another .js file and include it to the .js file that you want user to block. So if user access the .js file, the code will not shown.


However, the main case in which I want to really 'hide stuff' is when I'm publishing an email address.
Note, there is the problem of Chrome when you click on 'inspect element'. It will show your original code: every time. This is why obfuscation is generally regarded as being a better way to go.

Thanks for watching my blog. Do follow me on google+ or like my facebook page for more! :)
Obstrum Facebook Page


EmoticonEmoticon