I read this: http://net.tutsplus.com/tutorials/php/supercharge-your-css-with-php-under-the-hood/ And that tells me how to do what I was thinking was impossible. Now the hard part is…
I want php to output the page, then go through the page adding all of the classes, ids, and tags, to an array. Then use that array to select the CSS rules that would apply and write a css file to be linked from the page.
This would create one css file that only has the rules used on that page.
I’m thinking of this because I audited a site that has 5+ stylesheets and styles in the head, of which an average of 90% of the rules are not being used on one specific page, while being needed on another. So about 150k of data is being transferred for no reason at any given time. Not to mention all of the server requests.
So what do you guys/gals think of this?