|
Posted by Colin Ross on 10/21/91 11:11
I'm trying to compress down a php-powered javascript file.
In the file i have php run a bunch of loops and foreaches to build
huge nested arrays for use in the javascript.
Since this will be an often loaded page with ALOT of backend
processing, I've decided to compress the file as much as I can and
cache the resulting 'js' file.
Trimming whitespace, etc have been easy in the buffer i have, but I'm
having trouble trying to remove empty javascript satements that do
nothing but add to the page weight.
code:
/*
remove useless statements like " case '15': { break;} "
*/
$buffer = preg_replace('/case(\s)?\'(\d)\'(\s)?:(\s)?[{](\s)?(break;)?(\s)?[}]/',
'', $buffer);
I have a bad feeling that its something in my regex, but can't quite
tell... I want it to allow for spaces (only), 'break;' should be
optional. and any number.
I usually tend to understand regexs, not sure why this one isn't working out...
Colin
Navigation:
[Reply to this message]
|