Support » Plugin: Autoptimize » Blank Screen after Activating CSS-Optimization

  • Resolved pmcm

    (@pmcm)


    Hi,

    i tried to install your plugin on my site http://www.baby-cool.de but if i try to activate css-optimization, i just see a white blank screen. Even if i try to active “just look in head” the error is the same.

    html and js optimization are activated right now and work fine. but i don’t know why css doesn’t work.

    PS: I’m also usin WP Super Cache with mod_rewrite.

    http://wordpress.org/plugins/autoptimize/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Frank Goossens

    (@futtta)

    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

    That works! Thanks a lot!!!

    Plugin Author Frank Goossens

    (@futtta)

    @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?

    @futtta: Yes, no problem. What should i change?

    Plugin Author Frank Goossens

    (@futtta)

    2 changes actually;

    1. seeing if we get an error on the actual inclusion of the cssmin-library;

    1. 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');

    2. in wp-config.php remove
      define("AUTOPTIMIZE_LEGACY_MINIFIERS","true");
    3. empty autoptimize cache and see if you get an ugly error instead of a white screen
    4. if so, revert the 2 above changes
    5. 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.

    1. 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);
      }

    2. 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

    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.

    Plugin Author Frank Goossens

    (@futtta)

    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);
    }

    Plugin Author Frank Goossens

    (@futtta)

    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, …?

    Plugin Author Frank Goossens

    (@futtta)

    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!

    Plugin Author Frank Goossens

    (@futtta)

    and 1.7.2 is now live, fingers crossed the improvements in minifier-loading fix the blank screen problem.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Blank Screen after Activating CSS-Optimization’ is closed to new replies.