简体   繁体   中英

Is it possible to hide include part in view source of html

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> 

No.

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

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.

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/

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.

如果要避免人们阅读您的源代码,则必须切换到某种已编译的应用程序,例如C ++而不是Web应用程序。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM