WordPress.org

Ready to get started?Download WordPress

Forums

Autoptimize
[resolved] Blank Screen after Activating CSS-Optimization (11 posts)

  1. pmcm
    Member
    Posted 9 months ago #

    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/

  2. futtta
    Member
    Plugin Author

    Posted 9 months ago #

    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

  3. pmcm
    Member
    Posted 9 months ago #

    That works! Thanks a lot!!!

  4. futtta
    Member
    Plugin Author

    Posted 8 months ago #

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

  5. pmcm
    Member
    Posted 8 months ago #

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

  6. futtta
    Member
    Plugin Author

    Posted 8 months ago #

    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

  7. pmcm
    Member
    Posted 8 months ago #

    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.

  8. futtta
    Member
    Plugin Author

    Posted 8 months ago #

    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);
    }
  9. futtta
    Member
    Plugin Author

    Posted 8 months ago #

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

  10. futtta
    Member
    Plugin Author

    Posted 7 months ago #

    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!

  11. futtta
    Member
    Plugin Author

    Posted 7 months ago #

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

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.