2

I have all my javascript / jquery functions in a separate files, and need to prevent users from accessing this file. How can I do it ? Currently they can have a look at the source of the page and click on the following address to have access to this file.

My code is using the following line to have access to external functions on myfile.js file.

<script src="../myfiles/myfile.js"></script>

I do not want to deactivate double click on the page.

code_fish
  • 3,381
  • 5
  • 47
  • 90
Tim Norman
  • 421
  • 1
  • 12
  • 31
  • one way is that to restrict mouse right click and run your project in window also disable toolbar – shreyansh jogi Aug 23 '13 at 05:26
  • @shreyanshjogi any other method ? I am not interested in that. – Tim Norman Aug 23 '13 at 05:30
  • 4
    This is a really common question and in general it's impossible. If a user's browser can see a file, so can the user. You can read more here: http://stackoverflow.com/questions/2222355/how-to-hide-javascript-code – dcaswell Aug 23 '13 at 05:30
  • 3
    Why do you want to *keep it private*? If you simply don't want to show your code, you could [obfuscation](http://javascriptobfuscator.com) but it won't prevent somebody to understand your code. Just make it harder. – LaurentG Aug 23 '13 at 05:33
  • 2
    If it's online; it's public. – Ravi K Thapliyal Aug 23 '13 at 05:52
  • in short you cant; but you can expose what you need to expose and hide what you dont the world to know, a js file is downloaded so it is visible to everyone who accesses your site – ianace Aug 23 '13 at 07:07

1 Answers1

1

One way might be by using JS Encryption, so users reading your code won't be able to interpret it easily. Read more on http://javascript.about.com/library/blencrypt.htm

Nadeem_MK
  • 7,533
  • 7
  • 50
  • 61