In some -rare, this is only the 2nd time I see this- cases the new CSS optimizer backfires, leaving nothing but a blank page. In that case you can force Autoptimize to use the legacy CSS minifier by adding this to your wp-config.php:
define("AUTOPTIMIZE_LEGACY_MINIFIERS","true");
hope this helps,
frank
Thread Starter
pmcm
(@pmcm)
That works! Thanks a lot!!!
@pmcm; I’m working on 1.7.1 and would like Autoptimize to fail less … visible. Would you be willing make a small temporary change to autoptimizeStyles.php to see if that “fixes” the white screen?
Thread Starter
pmcm
(@pmcm)
@futtta: Yes, no problem. What should i change?
2 changes actually;
1. seeing if we get an error on the actual inclusion of the cssmin-library;
- in wp-content/plugins/autoptimize/autoptimize.php on line 117 change
@include(WP_PLUGIN_DIR.'/autoptimize/classes/external/php/yui-php-cssmin-2.4.8-1.php');
to
include(WP_PLUGIN_DIR.'/autoptimize/classes/external/php/yui-php-cssmin-2.4.8-1.php');
- in wp-config.php remove
define("AUTOPTIMIZE_LEGACY_MINIFIERS","true");
- empty autoptimize cache and see if you get an ugly error instead of a white screen
- if so, revert the 2 above changes
- if not, revert 1st change and continue to (2)
2. if you still have a white screen (i.e. no ugly error), this change aims to have autoptimize fail more gracefully.
- open wp-content/plugins/autoptimize/classes/autoptimizeStyles.php and on line 275 change
//Minify
if (class_exists('Minify_CSS_Compressor')) {
// legacy
$code = trim(Minify_CSS_Compressor::process($code));
} else if(class_exists('CSSmin')) {
$cssmin = new CSSmin();
$code = trim($cssmin->run($code));
}
into the safer
//Minify
try {
if (class_exists('Minify_CSS_Compressor')) {
// legacy
$tmp_code = trim(Minify_CSS_Compressor::process($code));
} else if(class_exists('CSSmin')) {
$cssmin = new CSSmin();
$tmp_code = trim($cssmin->run($code));
}
} catch (Exception $e) {
$CSSMinError = $e->getMessage();
$this->ao_logger("Could not minimize because: ".$CSSMinError);
}
if (!empty($tmp_code)) {
$code=$tmp_code;
unset($tmp_code);
}
- with the AUTOPTIMIZE_LEGACY_MINIFIERS still removed from wp-config.php, empty the autoptimize cache and try if you get a white page now
After these tests you can revert all changes, off course!
thanks for your help!
frank
Thread Starter
pmcm
(@pmcm)
Hi,
if i do first changes, i get an “HTTP500: Internal Server Error”.
An if i do the second changes, i just get a blank screen without any error message.
weird … an internal server error upon including the new cssmin-library?
could you try to change
@include(WP_PLUGIN_DIR.'/autoptimize/classes/external/php/yui-php-cssmin-2.4.8-1.php');
in wp-content/plugins/autoptimize/autoptimize.php into
try{
include(WP_PLUGIN_DIR.'/autoptimize/classes/external/php/yui-php-cssmin-2.4.8-1.php');
} catch (Exception $e) {
$CSSMinError = $e->getMessage();
$this->ao_logger("Could not load minimizer: ".$CSSMinError);
}
The internal server error is pretty weird, as it is caused by a simple inclusion of the cssmin-component (and not the minimization of CSS), so I’m thinking there might be a problem that is not purely related to the code here.
What system are you running your WordPress on? OS (Linux/ Windows/ …), webserver (Apache, IIS, ngix, ligthttpd, …), what version of PHP, what amount of memory available for PHP, …?
I’ve just pushed a first test-version of 1.7.2 to the plugin repository with some extra checks before loading the minifiers, so it might fix the blank screen problem. You can download the test-version here. Looking forward to your feedback!
and 1.7.2 is now live, fingers crossed the improvements in minifier-loading fix the blank screen problem.