Hiding the source CSS code

前端 未结 3 1244
后悔当初
后悔当初 2020-12-19 18:31

Hello recently i have seen sites ,that hides their source css when viewed their source! How is this exactly possible.. I assume some javascript may do the trick. this is a

相关标签:
3条回答
  • 2020-12-19 19:00

    There are tools like Firebug, Chrome Developer Tools and Web Developer Tools in almost all the major browsers and as how the browser sees the CSS and resources, they too see them in the same way and would get the CSS.

    I was saying about the resources like these:

    1. Firebug


      (source: getfirebug.com)

    2. Chrome Dev Tools

    3. F12 Web Developer Tools in Internet Explorer


      (source: microsoft.com)

    All these tools show the CSS file as well as what styles are inherited, and which elements inherit them.

    There is NO way to hide the client side components like CSS.

    What you are doing might slow down the performance of the browser and load time of the page, thereby annoying the visitors (if they are in large numbers) and becomes a usability problem.

    0 讨论(0)
  • 2020-12-19 19:07

    So is this code going to hide my css

    No

    or will fake the users the origin of css..?

    No


    It will make it very slightly harder to spot using View Source… but I haven't see anyone use that as the first approach to examine how a page works for years. DOM inspector tools will show the generated <link> element, and will show the styles applying to any given element along with a link to the stylesheet file they appear in. Network monitoring software (including that which is built into Firebug, Chrome Developer Tools, etc, etc) will show the HTTP requests and responses for the stylesheets too.


    What it will do, is delay any loading of the CSS until the JS has run. That is all.

    This may be so that some CSS is only used in browsers which have JS enabled (the CSS might hide some content which is then only revealed via JS interactions, so the author wants it to default to being visible if it can't later be revealed with JS).

    This may be so that the content loads first and gets styled later (as a hack to give content loading performance priority over content styling).

    0 讨论(0)
  • 2020-12-19 19:16
      Here is Code To Hide Css .
    

    First On javaScript

    $(window).load(function(){//Function call On Load windows
    
        $.post("Ajax.php?action=getCss",{},function(data){//Ajax Request To Css 
            $("#Corecss").html(data);// Paste css in Corecss Div without Shoing             
        });
     });//Thanks Hashaam zahid From Pakistan
    

    2)On Html

    <div id="Corecss"></div>
    

    3)on PHP Create Ajax.php File

    if($_GET['action']=='getCss')
    {
    $sDbServerName="localhost";$sDbUserName="***";$sDbPassword="*****";$sDbName="Data";// Connection with database server $dbConnect=mysql_connect($sDbServerName,$sDbUserName,$sDbPassword);if($dbConnect)
    {
    
          echo   '<link rel="stylesheet" href="css/creative.css" type="text/css">';
    
    
    }
    else
    {
        die("You Cannot Do it With Css");
    }
    
    
    }//Thanks From Hahshaam zahid     ( ittuc.com )  and facebook/HashaamKhan321
    
    0 讨论(0)
提交回复
热议问题