How to protect .js from download

Discussion in 'JavaScript' started by houssem-hj, May 10, 2008.

  1. #1
    Hi everybody.

    I have a .js file in one website, I don't want that this file can be downloaded or be shown in the source code of the file.

    I tried to protect the folder by an .htaccess file, with this solution i see that even the website can not use the script.

    Someone have an idea ??

    Thanks for your reply.
    Regards.
     
    houssem-hj, May 10, 2008 IP
  2. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #2
    If a site uses a script, it has to download it; once downloaded it can always be accessed.
     
    Logic Ali, May 11, 2008 IP
  3. Alex Polski

    Alex Polski Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can only encode .js-file, because javascript runs on client side but not server side.
     
    Alex Polski, May 11, 2008 IP
  4. dzdrazil

    dzdrazil Peon

    Messages:
    64
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    would it be possible to use something server-side instead of java? php or so?
     
    dzdrazil, May 11, 2008 IP
  5. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #5
    Javasource is a Client Side scripting language. This means that it must be downloaded to the viewers computer to be compiled and run. You can use things such as AJAX to pass data between server side languages such as PHP and javascript, to keep security and interactivity balanced.
     
    crath, May 12, 2008 IP
  6. hotmarket

    hotmarket Peon

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Try use referer check,but here only forbid direct to download,if the man use tool,here still can't work ok!
     
    hotmarket, May 12, 2008 IP
  7. GreatMetro

    GreatMetro Peon

    Messages:
    117
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
  8. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #8
    crath, May 13, 2008 IP
  9. vpguy

    vpguy Guest

    Messages:
    275
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Nonsense. It hardly slows it down at all. I use Packer on all of my scripts. If it slows down your script by 20 seconds, then your script needs some serious rewriting - it's not the tool that is to blame.

    To answer the OP's question: it cannot be done. Lots of people have tried lots of ridiculous things, but Javascript can only be obfuscated. Obfuscated code can quickly and easily be converted into the original source code.
     
    vpguy, May 14, 2008 IP
  10. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #10
    It will only slow down the people trying to get the code about 20 seconds, it will not slow down the scripts.
     
    crath, May 14, 2008 IP
    vpguy likes this.
  11. vpguy

    vpguy Guest

    Messages:
    275
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Ah... now I understand, and completely agree.
     
    vpguy, May 14, 2008 IP
  12. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #12
    you can encode it instead of hiding

    Javascript coders programs are available ,they just make it unreadable

    Regards

    Alex
     
    kmap, May 14, 2008 IP