SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot santanu's Avatar
    Join Date
    Oct 2003
    Location
    india
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Prevent viewing javascript code

    Is there any way to prevent viewing javascript code? If you browse any .js file it will show content of that file. As for example type this url http://www.googleadservices.com/pagead/conversion.js . You can view content of that .js file. How can i prevent to display content of .js file?

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't. If you want a user to be able to use Javascript on your page, then when they come to view your HTML page, their browser will download the JS, and there will be a way to view the JS in the cache of the browser. Firefox has an extension which is specifically designed to allow you to view external JS.

    However, you can download a Javascript compression tool, and realistically Javascript that has been compressed (where all of the variables have been renamed to things like x1, x2, x3, etc...) is extremely difficult to read and will prevent 99% of people from being able to reverse engineer your script.

    Also, I believe IE has a Javascript encryption tool available, but then your JS will only work in IE.

    Dave

  3. #3
    Web development Company chrisranjana's Avatar
    Join Date
    Jan 2001
    Location
    chennai , tamil nadu , India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is one example of Html and Javascript encryption and Javascript and html decryption
    Chris, Programmer/Developer, Chrisranjana.com
    Chennai, Tamil Nadu, India.
    Php Developers, Ruby on Rails Developers

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by santanu View Post
    How can i prevent to display content of .js file?
    Don't put it on the web.
    Seriously, that is the only reliable way.
    Birnam wood is come to Dunsinane

  5. #5
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't be ashamed of your code- it may seem ugly and embarassing to you,
    and maybe it is, but everyone has to start somewhere.

    The secret is to keep improving it, and have the last laugh on whoever it is that's using your old code.

  6. #6
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mrhoo View Post
    Don't be ashamed of your code- it may seem ugly and embarassing to you,
    and maybe it is, but everyone has to start somewhere.

    The secret is to keep improving it, and have the last laugh on whoever it is that's using your old code.

  7. #7
    SitePoint Zealot santanu's Avatar
    Join Date
    Oct 2003
    Location
    india
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    Don't put it on the web.
    Seriously, that is the only reliable way.
    AutisticCuckoo,

    If you have not capability to give answer or explain any issue please don't put your prank message to increase your number of posting. It is not expected from a senior member of sitepoint. I hope you will remember it in future.

  8. #8
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by santanu View Post
    AutisticCuckoo,

    If you have not capability to give answer or explain any issue please don't put your prank message to increase your number of posting. It is not expected from a senior member of sitepoint. I hope you will remember it in future.
    It was not a 'prank message' and I could not possibly care less about post count. I wouldn't use a word like 'seriously' in a prank, would I?

    I am trying to tell you the truth: you cannot prevent people from seeing your JavaScript code. Why? Because browsers need to 'see' it to run it, and if browsers can see it, so can people.

    You can obfuscate the code to make it more difficult to read for humans, but that will merely slow thieves down a bit. I will not 'prevent' theft.

    Don't blame the messenger if you don't like the message. Staff members have feelings too, you know.
    Birnam wood is come to Dunsinane


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •