Hide JavaScript code in external .js file?

Discussion in 'JavaScript' started by Mitchell, Mar 8, 2009.

  1. #1
    In reference to a website.
    I understand anyone can copy JavaScript code from a site. However it is unclear to me if JavaScript can be hidden securely in an external .js file just as css is kept in an external file.

    Is it possible to prevent the code from being viewed and copied without using some scrambler software that will slow down my site?

    Thanks.
     
    Mitchell, Mar 8, 2009 IP
  2. DGK

    DGK Peon

    Messages:
    73
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It is better to put the js code in external file, but you can't prevent the code from being copied, because js is browser-side script.
     
    DGK, Mar 9, 2009 IP
  3. siothach

    siothach Active Member

    Messages:
    656
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #3
    siothach, Mar 9, 2009 IP
  4. shubhamjain1

    shubhamjain1 Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Can be decoded easily.!!

    Dean Edwards JS packer is a good one but it can also be decoded easily by changing eval to document.write.!!!
     
    shubhamjain1, Mar 9, 2009 IP
  5. Mitchell

    Mitchell Peon

    Messages:
    204
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks everyone for your responses. Maybe PHP can be used to partially do some of what JavaScript would be doing to limit copying. I know PHP is on the server side. I will have to study up on how far the limits can be pushed.
     
    Mitchell, Mar 9, 2009 IP
  6. siothach

    siothach Active Member

    Messages:
    656
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #6
    yes, can be decoded easily, encryption only make more dif to see the plain code
     
    siothach, Mar 9, 2009 IP