It's most likely something that I'm doing wrong, but for whatever reason I can't seem to get AdvAgg to compress/gzip anything that's in my sites/all/themes/ folder. I've included a link to Imgur that has screenshots of Firebug in a non-admin browser showing the uncompressed/zipped files being loaded in the header, as well as my config screens for AdvAgg.

http://imgur.com/a/Z1quL

Any help would be very greatly appreciated. Thank you!

Comments

mikeytown2’s picture

Title: Not compressing/gzipping anything in sites/all/themes » Porto theme adds CSS incorrectly, thus CSS in sites/all/themes/porto can not be aggregated and compressed

Looks like the Porto theme is adding CSS to Drupal incorrectly. Unfortunately that is a paid theme so I can't offer a patch to fix the theme's code as I don't have the theme's code at hand. There are multiple ways to add CSS in Drupal and it appears that the porto theme is using #6 or #7 on the list and my guess is they are using #6 drupal_add_html_head()
http://wearepropeople.com/blog/7-ways-to-add-custom-js-and-css-to-a-page...

The reason I know this is the case is because the html is structured like so with the title in the middle of the CSS.

...
<link href="/sites/all/themes/Porto/css/theme-responsive.css" rel="stylesheet" type="text/css" media="screen" />
<title>SML - Moving Made Simple | Moving Help, Local Movers, Full Service Moving</title>
<link type="text/css" rel="stylesheet" href="https://www.simplemovinglabor.com/sites/default/files/advagg_css/css__BJ6Ou6QsBRtnFTmxaakamOIS8n4QswDP2XnnZ1sxtaM__6IoRHYuSXh6SbzUfNwtQM7aMuzK7qJzxXyTOLAksHnM__GhEEd3QOKIFAsIapJrMEuhIMUDqhQpvE7MSDRsLbij4.css" media="all" />
...

If the CSS was added in correctly it wouldn't have a title tag in the middle.

In terms of options, the best one is to have the CSS be added correctly by the theme.

I'll be working on an alternative that will look through the html_head code for CSS and/or JS that was added in incorrectly https://api.drupal.org/api/drupal/modules!system!system.api.php/function...

cwschimpff’s picture

Mikey,

Thanks for your fantastic sleuthing!

Assuming I go into template.php and remove all drupal_add_html_head() calls and replace them with drupal_add_css() calls, do you think that would solve the issue and allow AdvAgg to compress/gzip them properly?

mikeytown2’s picture

I think that would do the trick. When adding the CSS I would set a couple of options so that the theme CSS shows up first (like it currently does).

drupal_add_css('.../Porto/css/theme-responsive.css', array(
  'group' => -300,
  'media' => 'screen',
));
cwschimpff’s picture

Ever been somebody's hero for the day? If not, today's your lucky day. That worked like a charm.

Thank you so much for taking time out of your day to help me with this! Should I mark the issue 'closed'?

mikeytown2’s picture

You can go ahead and set the status to "Closed (works as designed)" :)

cwschimpff’s picture

Status: Active » Closed (works as designed)