How to protect a file...

Discussion in 'Site & Server Administration' started by WizardRSS, Jul 31, 2010.

  1. #1
    I am not even sure if this is possible but I decided try it out anyways.

    I have a certain javascript file that I want to let me display the contents of on their website. I am giving them this code so that they can easily add the contents:

    <script type="text/javascript" src="http://www.website.com/thefile.js"></script>
    Code (markup):
    However, I don't want people to be able to actually go directly to http://www.website.com/thefile.js and get codes that are in the file. Is it possible for me to protect myself against this? I want people to be able to display the information on their website, but not be able to see the javascript coding.

    Please and thank you ;)
     
    WizardRSS, Jul 31, 2010 IP
  2. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #2
    If you want the browser to be able to run the JS then people will be able to see it, about the best you can do is use a JavaScript compressor/obfuscator to make the code hard to read.
     
    tolra, Aug 1, 2010 IP
  3. DoDo Me

    DoDo Me Peon

    Messages:
    2,257
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #3
    compress the JS is the way and the only way to go. You can compress the JS on the fly or compress it when every time it changes
     
    DoDo Me, Aug 3, 2010 IP