Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. hide ajax files

hide ajax files

Scheduled Pinned Locked Moved ASP.NET
javascriptcsstoolshelpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Morgs Morgan
    wrote on last edited by
    #1

    hi guys, my site will be using ajax methods and i don't want clientside to view my ajax(js) code when they view the source code of my site.. Does anyone know how i can hide my ajax files so that they are not viewable on clientside? For instance you can import a css file using the @Import command..I tried something similar in javascript with below code:

    var script = document.createElement('script');
    script.src = '../ajax/login/login.js';
    script.type = 'text/javascript';
    document.getElementsByTagName('head').item(0).appendChild(script);

    with the above, none of my methods in the login.js file are loading... Please help me.

    N M T 3 Replies Last reply
    0
    • M Morgs Morgan

      hi guys, my site will be using ajax methods and i don't want clientside to view my ajax(js) code when they view the source code of my site.. Does anyone know how i can hide my ajax files so that they are not viewable on clientside? For instance you can import a css file using the @Import command..I tried something similar in javascript with below code:

      var script = document.createElement('script');
      script.src = '../ajax/login/login.js';
      script.type = 'text/javascript';
      document.getElementsByTagName('head').item(0).appendChild(script);

      with the above, none of my methods in the login.js file are loading... Please help me.

      N Offline
      N Offline
      NeverHeardOfMe
      wrote on last edited by
      #2

      By definition, a client side file (which your ajxx/javascript files are) are sent to the client. In plain text. So no matter what you do, you cannot stop a determined user from viewing them. You can minify and obfuscate them, but while that may deter an inexperienced user, it won't stop anyone that knows what they are doing. But the question is: why do you want to? Never, ever, put sensitive data in a javascript file.

      1 Reply Last reply
      0
      • M Morgs Morgan

        hi guys, my site will be using ajax methods and i don't want clientside to view my ajax(js) code when they view the source code of my site.. Does anyone know how i can hide my ajax files so that they are not viewable on clientside? For instance you can import a css file using the @Import command..I tried something similar in javascript with below code:

        var script = document.createElement('script');
        script.src = '../ajax/login/login.js';
        script.type = 'text/javascript';
        document.getElementsByTagName('head').item(0).appendChild(script);

        with the above, none of my methods in the login.js file are loading... Please help me.

        M Offline
        M Offline
        Muhammad Mazhar
        wrote on last edited by
        #3

        Try using some encryption or obfuscation method to secure your client side javascript.

        I Web Development Free Lancer
        Share your experience with others Check my Blog...

        1 Reply Last reply
        0
        • M Morgs Morgan

          hi guys, my site will be using ajax methods and i don't want clientside to view my ajax(js) code when they view the source code of my site.. Does anyone know how i can hide my ajax files so that they are not viewable on clientside? For instance you can import a css file using the @Import command..I tried something similar in javascript with below code:

          var script = document.createElement('script');
          script.src = '../ajax/login/login.js';
          script.type = 'text/javascript';
          document.getElementsByTagName('head').item(0).appendChild(script);

          with the above, none of my methods in the login.js file are loading... Please help me.

          T Offline
          T Offline
          T M Gray
          wrote on last edited by
          #4

          In general, you can't hide something from the client if you need the client to use it. My suggestion would be to convert all your js files to aspx files and set the content type. Have them do a referer check and set the caching options to not cache. It won't be good for performance and it won't stop a seriously determined person, but it should be a pretty big speed bump to most people.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups