Possible to obfuscate CSS?

Heres something that I have been pondering on. What with the way my sites are moving - content split completely from the design - is it possible to obfuscate my CSS so people can’t know how I’ve created my styling?

I suspect the answer here is no. As it’s not as simple as obfuscating code.

If it were possible I would think there would be a huge market for that snippet of code. I bet the JavaScript gurus have asked the same question. :slight_smile:

You can obfuscate javascript no problem. There are helpfull programs out there to give you a hand too. They simply mess up the code but preserve the syntax and semantics of it so that it can still run.

Thats why I think it would be hard, if not impossible to do it to CSS as the browsers need to know everything as is. Anyone know any different?

And why would you need that? Even obfuscated there’ll be ways around to get your stylesheet (cached copies, generated code, simulating a browser with offline browsers).

Obfuscating javascript, css or trying to make images stealproof on the client side is a waste of time, and frankly smacks of narcism.

I am happy if people get an inspiration from my CSSZengarden sheet or the scripts I use on my various sites, and gladly give curious people a job. Part of being a good web developer is to know who to copy from or what to study in detail, in an environment as undefined as the web that is the only way to be up to date, as books and courses age very fast.


Look, normally I don’t care - infact I’ve never actually obfuscated anything before - I only ask since I am creating quite a unique piece of styling that my client would like to keep to themselves at least for yay long a period of time!

Hardly narcisistic. . . just simple economics - besides one of their competitors has been updating their site to match elements of my clients for some time now!

One of our clients is mcdonalds, and ****mcdonalds.co.uk keeps copying our efforts 1:1. You got to live with that, this is what it boils down to on the web. You can put a copyight notice in the CSS and in the disclaimer though that this or that design is copyrighted. Then let their lawyers fight it out…

To be a bit more helpful:
What you can do is - granted the effect is eyecandy only - to generate the necessary elements via Javascript and DOM and apply the styles as object attributes. Then obfuscate the Javascript with dean edwards’ packer http://dean.edwards.name/packer/

Another option is to generate the CSS via PHP (setting a CSS header), and ensure that caching is off, that’ll mean though that your server load goes up and the user cannot have any CSS caching.

Thanks for the input. I’ll look into this - but as you say. . . for the sake of my sanity it may be easier to have the men in suits wrangle it out.

I’d say don’t bother. A quick Ctrl+Shift+I in Mozilla or Firefox would reveal all your secrets anyway. :wink: