Protecting JavaScript Code.

Discussion in 'Programming' started by advancedfuture, Apr 2, 2008.

  1. #1
    I have been developing JavaScript code for one of my new website projects. It is very VERY important that my quoting algorithm is kept out of my competitions hands as this will set me apart from almost all my competition.

    Is there a way I can protect my JavaScript code?
     
    advancedfuture, Apr 2, 2008 IP
  2. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #2
    Encode it may be.
     
    it career, Apr 3, 2008 IP
  3. fairuz.ismail

    fairuz.ismail Peon

    Messages:
    232
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    or you can use ajax. Put all your algorithm in a PHP file, then call it using javascript. I think it is the best way to protect your script.
     
    fairuz.ismail, Apr 3, 2008 IP
  4. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If it is javascript then it has to be sent to the client and their browser must be able to interprit it and so cannot be hidden from them. The only way to truly hide it is to have the calculation done server side with .Net/ PHP/ JSP etc as that way the algorithm is never sent to them... you can use AJAX to get a smoother process if that is important to you.
     
    AstarothSolutions, Apr 3, 2008 IP
  5. Gyrotive

    Gyrotive Guest

    Messages:
    15
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You could just write the code in php and include that on your webpage instead of including the javascript. This way the algorithm wouldn't be displayed as it would be parsed server side, and the results would be fed to the browser with a simple echo statement at the end. Pretty much what's already been said.
     
    Gyrotive, Apr 3, 2008 IP