.js help

iamalion

n00b
Joined
Jul 23, 2009
Messages
14
I am wondering if anyone knows how to block someone from going to www.websitehere.com/scripts/script.js, but allowing it to be called in a webpage via <script src="/scripts/script.js" type="text/javascript"></script>.

I have tried everything I can think of but I am totally lost...
 
What exactly are you trying to do - prevent people from hotlinking your JS (like linking to it and using it from another website), or preventing people from seeing your javascript at all?

If it's the former, you can use .htaccess (or similar for your particular web server). If the latter - the very nature of how web pages are served up makes it pretty tough to do (the browser can cache JS files).
 
You can load an external javascript file in via ajax. Also you can obfuscate the javascript.

Either way though, people will be able to see the contents somehow, since it is being sent to their web browser.
 
What specifically is in the Javascript file that you want hidden from the users?
 
Back
Top