At the partner day Hiugh showed us this method to compress/minify css: it works in v18 and v16 but NOT in v14 and v12.
Can anyone explain what is different in v14/12 that causes this error?
Here is the Compression php stuff:
Thank you
Code:
Parse error: parse error in main on line 3
Here is the Compression php stuff:
Code:
This technique uses PHP and regular expressions. Put this before the CSS <actinic:block php="true"> $sCSS = <<<'CSSDefinition' and this at the end: CSSDefinition; <actinic:block if="%3cactinic%3avariable%20name%3d%22IsCompressionEnabled%22%20%2f%3e"> // Clean up CSS $sCSS = preg_replace('/\\r|\\n/', ' ', $sCSS); // eliminate newlines $sCSS = preg_replace('/\s+/', ' ', $sCSS); // convert all multiple tabs and spaces to a single space $sCSS = preg_replace('/\/\*.*?\*\//', '', $sCSS); // remove all comments $sCSS = preg_replace('/\s*(\{|\}|:|;|,|>|\/)\s*/', '${1}', $sCSS); // eliminate spaces either side of { } : ; , > / $sCSS = preg_replace('/([^0-9])0px/', '${1}0', $sCSS); // convert 0px to 0 $sCSS = preg_replace('/^\s*/', '', $sCSS); // remove spaces remaining at start of CSS $sCSS = preg_replace('/([^\'])#([0-9a-fA-F])\2([0-9a-fA-F])\3([0-9a-fA-F])\4/', '${1}#${2}${3}${4}', $sCSS); // convert colours like #aabbcc to #abc $sCSS = preg_replace('/(padding|margin):([0-9]+(?:px|%)+) \2;/', '${1}:${2};', $sCSS); // convert margin:0 0; to margin:0; $sCSS = preg_replace('/(padding|margin):([0-9]+(?:px|%)+) \2 \2 \2;/', '${1}:${2};', $sCSS); // convert margin:0 0 0 0; to margin:0; $sCSS = str_replace(' !important', '!important', $sCSS); // remove space before !important $sCSS = str_replace(';}', '}', $sCSS); // get rid of trailing ; in rules </actinic:block> echo $sCSS; </actinic:block>
Comment