简体   繁体   中英

How to hide a javascript file?

My question is : how can you hide a javascript file even if you need to use it ?

It is possible to denied access to the source code of a javascript file ? Like if I insert it in my page, functions and other stuff will work but when someone try to access it directly or whatever, it will fail. Any ideas ?

I've done some research but didn't found what I really wanted.

The short answer, no it can not.

If its being executed, its being seen.

Because javascript is an interpreted language (not compiled) a copy of the source code has to be copied to the users computer. There is no way to stop them from looking at it on their hard drive or using the built in functions of their browser.

If you're transmitting a file to a user, they can look at it.

The only to guarantee a user can't look at the contents of a file is to not send it to them.

http://www.stunnix.com/prod/jo/

You can use this tool or similar ones to make it harder for your code to be human readable, but you can't stop people from looking at the code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM