CSS Gzip creates a Print stylesheet even if there are no modules or custom stylesheets that uses it. This results in a unnecessary call http call to an empty file.

Comments

mikeytown2’s picture

Status: Active » Postponed (maintainer needs more info)

CSS Gzip only grabs whats there, it doesn't write/change the html. I need more details. Here's the code that does the magic

/**
 * Implementation of hook_preprocess_page() or template_preprocess_page().
 *
 * Does not modify the pages contents, only gets info. Could probably use
 * drupal_get_css() and a different hook, if needed.
 *
 * @param &$variables
 *   Array containing various page elements.
 */
function css_gzip_preprocess_page(&$variables) {
  $htaccess = file_directory_path() . CSS_GZIP_DIR . '.htaccess';
  if (!variable_get('css_aggregator_gzip', FALSE) || variable_get('css_aggregator_gzip_no_htaccess', FALSE)) {
      css_gzip_remove_htaccess($htaccess);
    }
  if (!empty($variables['styles']) && variable_get('preprocess_css', FALSE) && variable_get('css_aggregator_gzip', FALSE)) {
    if (!variable_get('css_aggregator_gzip_no_htaccess', FALSE) && (file_exists($htaccess)==FALSE || variable_get('css_aggregator_gzip_htaccess_size', NULL)!=filesize($htaccess))) {
      css_gzip_create_htaccess($htaccess);
    }

    $css_files = css_gzip_file_list($variables);
    // Create the GZip file if it doesn't already exist.
    foreach ($css_files as $css_file) {
      if (file_exists(file_directory_path() . CSS_GZIP_DIR . $css_file) && !file_exists(file_directory_path() . CSS_GZIP_DIR . $css_file .'.gz')) {
        file_save_data(gzencode(file_get_contents(file_directory_path() . CSS_GZIP_DIR . $css_file), 9), file_directory_path() . CSS_GZIP_DIR . $css_file .'.gz', FILE_EXISTS_REPLACE);
      }
    }
  }
}
daemon’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

You're right, it was caused due to the theme.

Thanks for linking me the code.