Closed Thread Icon

Topic awaiting preservation: Dynamically change a css file (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=29209" title="Pages that link to Topic awaiting preservation: Dynamically change a css file (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Dynamically change a css file <span class="small">(Page 1 of 1)</span>\

 
paritycheck
Bipolar (III) Inmate

From: you tell me
Insane since: Mar 2004

posted posted 05-13-2007 08:53

OK I wasn't sure where to post this but anyway.. I wanna build a simple php script that alters a css file i.e. the user can set a few constants which would be stored in a database and those constants would be used to create a css file that would be used throughout the website.

I heard of how you can also call a php file to behave as a css file by getting it send the right headers but I've heard that has a speed issue. ANyway like whats the best way to get this done.. I mean the site has a very fixed structure - no design images nothing just a few colors and text,link colors that need to be dynamically changed..

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

posted posted 05-13-2007 12:55

Well, unless your CSS file is ridiculously big, let's say 50-100kb, and require some complex logic to retrieve the variables, I doubt you'll see any noticeable delay. A small dynamic site hardly take more than 0.1 second to load its data from a DB and build the markup, so that should be a fraction of that for just a few variables.

Also if your site has a lot of traffic you might want to cache the CSS somehow. That shouldn't be difficult since the settings are bound to the user.

Another thing, you should probably make use of the "C" in CSS. Put all the generic/default style rules in one static CSS file, and serve dynamically the smaller and user specific one. One may object against the extra HTTP request, but the browsers will cache the static CSS file at first sight.

Hope that helps,



(Edited by poi on 05-13-2007 12:59)

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 05-13-2007 12:59

A php-css file is no trouble at all - provided you have the right caching ( ie. you set correct 'last-modified' headers), no speeed issue at all.
Actually, this very board uses that technique.

« BackwardsOnwards »

Show Forum Drop Down Menu