简体   繁体   中英

Load an embeded js into a page using php to hide it in the source?

ive got a script i need to load into a page but its sensitive so i dont want to have to reveal the source of the script. Im aware that js runs client side, but is there some way i could load it server side with php / or just embed it server side to still be run on the users system?

The script itself is a simple external js script like this:

<script type="text/javascript" src="myscripts.js"></script> 

cheers

If you want your browser to run a script, it must receive the source code for that script. Your statement "embed the script server side" doesn't make much sense, nor does "loading it server side with.php". Either the browser receives the script code to execute (and thus, it is visible to the end-user), or it doesn't.

You can try using various obfuscation methods to make the source code harder to understand, but anyone with sufficient determination will get around this.

You could conceal the source location of the script that way, but not the source code. If you want it to execute on the client then you must sent it to the client. If you send it to the client then the user can execute it. Don't put secret business logic on the client side, handle it server side.

No there is not. The best you can do is to obfuscate your code to make it hard to reverse-engineer for non experienced user.

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