After installing and enabling the CSSTidy module, my CSS files do not seem to get Gzipped anymore by CSS Gzip module. YSlow is complaining that I should Gzip these files (and before it was not). Furthermore, in the "Components" view of YSlow I can see that the file size of the CSS files itself got lower (due to CSStidy probably) but that there is not Gzip filesize anymore.

Comments

philbar’s picture

Status: Active » Postponed (maintainer needs more info)

I have GZip working fine on my install. Let me look into #829216: "Division by zero" error and see if that fixes your problem.

philbar’s picture

Status: Postponed (maintainer needs more info) » Active

Nope, this is not going to be related to the previous issue.

philbar’s picture

Status: Active » Postponed (maintainer needs more info)

Did you enable CSS Gzip after CSSTidy?

jaochoo’s picture

No, I installed and enabled CSS GZip first and found CSSTidy later on.

graytoby’s picture

I'm having the same issue. I have 2 css files after aggregation, first one is generated by Data URI Sprites module, and this one gets compressed. Second gets processed by CSSTidy, but skips Boost compression. Perhaps module weight issue?

philbar’s picture

See if this fixed it: http://drupal.org/cvs?commit=403084

It should be in the dev tonight.

This issue might not be happening to me because I have CSS Embedded Images enabled which has the same code.

philbar’s picture

Status: Postponed (maintainer needs more info) » Fixed
graytoby’s picture

Status: Fixed » Active

Nope, after installing dev version, css images won't load. I'm going to try css embedded images modules and see if that makes a difference.

Edit: No luck with embedded image. No compression at all, I tried both, stable and dev version.

philbar’s picture

Did you get the dev for "2010-Aug-06"?

This is the fix I added: http://drupal.org/cvs?commit=403084

Is it in yours?

philbar’s picture

The fix is for CSS Gzip. Perhaps we need one for Boost as well.

philbar’s picture

Can you try the following?

In csstidy.module, after the following code (it's near the top of the file):

    // Move css_gzip's preprocess function after ours.
    if ($key = array_search('css_gzip_preprocess_page', $theme_registry['page']['preprocess functions'])) {
      unset($theme_registry['page']['preprocess functions'][$key]);
      $theme_registry['page']['preprocess functions'][] = 'css_gzip_preprocess_page';
    }

add:

    // Move boost's preprocess function after ours.
    if ($key = array_search('boost_preprocess_page', $theme_registry['page']['preprocess functions'])) {
      unset($theme_registry['page']['preprocess functions'][$key]);
      $theme_registry['page']['preprocess functions'][] = 'boost_preprocess_page';
    }

I'm sorry I can't be more helpful, but since I can't reproduce the issue, I'm having to rely on you.

philbar’s picture

graytoby’s picture

Version: 6.x-1.3 » 6.x-1.x-dev

I added the code to the dev version. With data uri sprites module, css images won't show, request for that css file returns 404, so I can't tell if it's compressed or not. With css embedded images still no compression.

philbar’s picture

I would recommend using CSS Embedded Images over Data URI Sprites. They are likely going to merge soon.

Perhaps you should use CSS Gzip until we get this issue sorted out.

graytoby’s picture

Css embedded images+css gzip didn't work. The end result is lack of css file. Looks like the best configuration for me at the moment is boost+parallel+data uri sprites.

philbar’s picture

A comparison of hook_theme_registry_alter(). CSSTidy and CSS Embeded Image have identical code here. It looks like Parallel and Data URI Sprites also have the same code but is missing the part which moves CSS GZIP's preprocess after our module's preprocess. It's still not clear what could be the issue here.

CSSTidy

/**
 * Implementation of hook_theme_registry_alter().
 * 
 * Make csstidy's page preprocess function run after everything else.
 * If the css_gzip module is installed, move it's preprocess function after ours.
 */
function csstidy_theme_registry_alter(&$theme_registry) {
  if (isset($theme_registry['page'])) {
    // Move our preprocess function after everything else.
    if ($key = array_search('csstidy_preprocess_page', $theme_registry['page']['preprocess functions'])) {
      unset($theme_registry['page']['preprocess functions'][$key]);
    }
    $theme_registry['page']['preprocess functions'][] = 'csstidy_preprocess_page';
    // Move css_gzip's preprocess function after ours.
    if ($key = array_search('css_gzip_preprocess_page', $theme_registry['page']['preprocess functions'])) {
      unset($theme_registry['page']['preprocess functions'][$key]);
      $theme_registry['page']['preprocess functions'][] = 'css_gzip_preprocess_page';
    }
  } 
}

Parallel

/**
 * Implementation of hook_theme_registry_alter().
 *
 * Make Parallel's page preprocess function run *after* everything else's,
 * so that a theme can't call drupal_get_js() and mess everything up.
 *
 * @param &$theme_registry
 *   The entire cache of theme registry information, post-processing.
 */
function parallel_theme_registry_alter(&$theme_registry) {
  if (isset($theme_registry['page'])) {
    // If parallel's preprocess function is there already, remove it.
    if ($key = array_search('parallel_preprocess_page', $theme_registry['page']['preprocess functions'])) {
      unset($theme_registry['page']['preprocess functions'][$key]);
    }
    // Now tack it on at the end so it runs after everything else.
    $theme_registry['page']['preprocess functions'][] = 'parallel_preprocess_page';
  }
}

Data URI Sprites

/**
 * Implementation of hook_theme_registry_alter().
 *
 * Make our page preprocess function run *after* everything else's,
 * so that a theme can't call drupal_get_js() and mess everything up.
 */
function data_uri_sprites_theme_registry_alter(&$theme_registry) {
  if (isset($theme_registry['page'])) {
    // If our preprocess function is there already, remove it.
    if ($key = array_search('data_uri_sprites_preprocess_page', $theme_registry['page']['preprocess functions'])) {
      unset($theme_registry['page']['preprocess functions'][$key]);
    }
    // Now tack it on at the end so it runs after everything else.
    $theme_registry['page']['preprocess functions'][] = 'data_uri_sprites_preprocess_page';
  }
}
philbar’s picture

Status: Active » Fixed

Replacing our code with Parallel's code. They are nearly identical, so not sure if it's fixed.

Unless this bit is causing this problem (which has been removed):

    // Move css_gzip's preprocess function after ours.
    if ($key = array_search('css_gzip_preprocess_page', $theme_registry['page']['preprocess functions'])) {
      unset($theme_registry['page']['preprocess functions'][$key]);
      $theme_registry['page']['preprocess functions'][] = 'css_gzip_preprocess_page';

http://drupal.org/cvs?commit=411256

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jaochoo’s picture

Css embedded images+css gzip didn't work. The end result is lack of css file. Looks like the best configuration for me at the moment is boost+parallel+data uri sprites.

I am using CSS embedded images + CSS GZIP + Parallel and it works. It's just CSSTidy which seems to blow up everything. ,-)

philbar’s picture

Are you using the latest dev of CSSTidy?

I didn't add the fix to version 1.3.

jaochoo’s picture

No, sorry, we already launched and so we did not use CSSTidy anymore. Maybe I'll try the latest version on a test machine later on.