Skip to content Skip to sidebar Skip to footer

Hiding The Source Css Code

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 piece o

Solution 1:

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).

Solution 2:

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

    (source: How to View and Edit CSS in Chrome Developer 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.

Solution 3:

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 Showing            
    });
 });//Thanks Hashaam zahid From Pakistan

In the HTML:

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

In PHP, create an 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

Post a Comment for "Hiding The Source Css Code"