I want to prevent other people from using my Javascript files. I know you can block them in the htaccess file like this, but is there a bit of code you can add that basically says if this file is not being run on [domain] then don't work?
Asked
Active
Viewed 73 times
1 Answers
6
This is impossible. All Javascript code is downloaded to the browser and executed locally which means that it will be readable by anybody. If you want your code to be "secret" then Javascript is not the right tool for this.
You can obfuscate it but that still is not a guarantee that someone won't be able to make sense out of it.

Icarus
- 63,293
- 14
- 100
- 115
-
5+1. If you're that concerned with security, write a server-side process to communicate with the client code. – Chris Eberle Jan 17 '14 at 20:03