0

I have searched many on this forum to hide some information in view source like script include and css, I didn't find any working solution

this is what I am doing in my php script

     <html>
           <head><?php include('mylibrary/my_include.php');?></head>

        <body>
             <div></div>
        </body>

     </html>

in view source I am getting like this

<html>
     <head>
      <!-- My function -->
      <script type='text/javascript' src='Library/My_fun.js'></script>

      <!-- Index -->
      <link type="text/css" rel="stylesheet" href="Index/Index.css" />
      <link type="text/css" rel="stylesheet"  href="JS/jquery-ui.css" />
     </head>

     <body>
        <div></div>
     </body>

</html>

I would like to hide js and css in view source which are in 'mylibrary/my_include.php', Is it possible to do so ? or any alternate solution displaying only following in viewsource or any other

     <head><?php include('mylibrary/my_include.php');?></head> 
user3304642
  • 181
  • 1
  • 2
  • 16

5 Answers5

5

No.

You can't give something to the browser without giving it to the user. The user controls the browser, you do not.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
3

I would like to hide js and css in view source which are in 'mylibrary/my_include.php', Is it possible to do so ? or any alternate solution displaying only following in viewsource or any other

No, it is impossible to render your page without these references due to the fact using these references, the web browser knows from where to download, parse and load your resources (css, js).

But:

You can obscure/compress/minify your JS & CSS files in such a way that it would be very hard for the users to identify it correctly.

UPDATE:

Per the OP request, here is how to compress resource files: http://refresh-sf.com/yui/

Yair Nevet
  • 12,725
  • 14
  • 66
  • 108
3

This is not possible. The browser needs to see it. Thus, the user is able to see it too.

There are methods you could use like obfuscating, disabling right clicks, etc., but these only work to prevent a small number of users from viewing it.

Anonymous
  • 11,748
  • 6
  • 35
  • 57
2

You can not hide the source html / javascript as they are run on client. You can obfuscate at max still one would be able to get to the source.

Adil
  • 146,340
  • 25
  • 209
  • 204
2

Yo'll have to switch to some kind of compiled application, like one in C++ instead of web application if you want to avoid people reading your sources.

Oscar
  • 13,594
  • 8
  • 47
  • 75
  • @Peter I don't understand what do you mean with "demo".. I can point you to an article where you can explore the possibilities of decompiling native C code, if that helps.. http://www.codeproject.com/Articles/4210/C-Reverse-Disassembly – Oscar Mar 25 '14 at 15:15
  • I don't know how to use it so I asked for demo – user3304642 Mar 25 '14 at 15:41
  • What I'm saying is that if you want to make almost impossible to reverse engineer your code, you need to change the way you distribute your application, making it a desktop application rather than a web one. I can't give you a demo of a native C++ application, there are hundreds of sites . Other option is to remove the relevant part from the JS and execute it at the server side instead of client side. – Oscar Mar 25 '14 at 16:15