Forum Moderators: coopster

Message Too Old, No Replies

PHP Speedy and Style Switcher

         

Sigmund Fraud

3:22 pm on Jul 31, 2008 (gmt 0)

10+ Year Member



I'm currently working on a dynamic website project, using a URL variable to pass the correct page to be included in a template (index.php).

I currently use the UDASSS style switcher (PHP style switcher and a degradable AJAX front end) and wanted to use PHP Speedy to improve the load times of the site, the problem is both want to be at the top of the execution order in the script, if I put Speedy anywhere in or above the head tags (it's supposed to go before the doctype) the CSS breaks.

Here is the code in question without the Speedy code:
(I've removed some the script calls UDASSS needs to make the example shorter.)


<?php
require_once('utils/style-switcher.php');
$styleSheet = new AlternateStyles();
$styleSheet->add('css/styledark.css','screen,projection','Dark');
$styleSheet->add('css/stylelight.css','screen,projection','Light',true);
$styleSheet->getPreferredStyles();
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<script type='text/javascript' src='js/prototype.js'></script>
<script type='text/javascript' src='js/alternateStyles.js'>
<?php $styleSheet->drop(); ?>
</head>

Style Switcher requires the first 5 lines of code to be at the top of the document, PHP Speedy requires the following lines to be at the top:


require_once('class.compressor.php'); //Include the class. The full path may be required
$compressor = new compressor('css,javascript,page');

Does anyone know how I could get the two to place nicely together?

[edited by: eelixduppy at 7:14 pm (utc) on July 31, 2008]
[edit reason] removed links [/edit]

paulmadillo

3:55 pm on Jul 31, 2008 (gmt 0)

10+ Year Member



I think I read a post about this from a guy called 'Fergal_Hunter'.
I'll have a look round and see if I can find it.

Sigmund Fraud

9:41 am on Aug 1, 2008 (gmt 0)

10+ Year Member



Many thanks; I had a look on the search, but could only find this thread. I wasn't able to find anything on the forums for UDASSS or PHP Speedy; unless it was just header modification in general?

Eelix: Sorry about the links, I made sure not to have any links to the site, or anything that could be used to identify it and then completely forgot the rule at the end. Used to people getting annoyed if somebody doesn't post links to something they're talking about.

[edited by: Sigmund_Fraud at 9:43 am (utc) on Aug. 1, 2008]

paulmadillo

12:49 pm on Aug 1, 2008 (gmt 0)

10+ Year Member



yeah, sorry. I think it was on a different forum and I can't find it for you.

jatar_k

3:47 pm on Aug 1, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the 2 require_once calls shouldn't have anything to do with the issue so you could put those up there

I look at this and wonder if the answer is there
$compressor = new compressor('css,javascript,page');

I wonder what compressor does with css? maybe just remove it, maybe not.

a look into the compressor function should give you a clue