Via hook_preprocess_html() I added google fonts stylesheet via drupal_add_html_head_link():

  drupal_add_html_head_link(array(
    'rel' => 'stylesheet',
    'type' => 'text/css',
    'href' => 'https://fonts.googleapis.com/css?family=Open+Sans:400,300,400italic,600,300italic|Source+Sans+Pro:600,400',
  ));

That worked well until enabling the advagg modifier option "Move CSS added by drupal_add_html_head() into drupal_add_css()" and " Move all external CSS to the top of the execution order". The website didn't include the fonts anymore.

It seems it's due to execution order (but I am not entirely sure), where hook_preprocess_html() is called fist, then advagg_mod_css_alter(), where the css added by drupal_add_html_head_link() is not yet in the array of css items and thought couldn't be moved to the top of of execution order and won't be outputted together with the other css. Finally advagg_mod_html_head_alter() is getting called where the head link css is moved to the list of css items and removed from the list of head links. But that seem to happen to late as css got already outputted (as hook_css_alter alters "CSS files before they are output on the page").

I am wondering if the option "Move CSS added by drupal_add_html_head() into drupal_add_css()" works at all or if I missed something in the execution order.

The solution in my case was to include the css script as supposed with drupal_add_css():

drupal_add_css('https://fonts.googleapis.com/css?family=Open+Sans:400,300,400italic,600,300italic|Source+Sans+Pro:600,400', array(
    'type' => 'external',
    'group' => CSS_THEME,
    'every_page' => TRUE,
  ));
CommentFileSizeAuthor
#4 advagg-2657894-4-fix-move-css.patch1.09 KBmikeytown2

Comments

osopolar created an issue. See original summary.

mikeytown2’s picture

Thanks for the bug report with code! I'll take a look here in a little bit

mikeytown2’s picture

Looks like I won't be able to get to this till tomorrow.

mikeytown2’s picture

Status: Active » Fixed
StatusFileSize
new1.09 KB

Looks like this functionality was broken when dns_prefetch was added. drupal_get_html_head() has been split up

  • mikeytown2 committed 2d8fc74 on 7.x-2.x
    Issue #2657894 by mikeytown2: Fix issue with moving css/js added to the...

  • mikeytown2 committed c4bfc34 on 7.x-2.x
    Issue #2657894 by mikeytown2: Fix issue with moving css/js added to the...
mikeytown2’s picture

Committed this
http://cgit.drupalcode.org/advagg/commit/?id=c4bfc34

Omega theme was causing issues so I re-worked how the alter is done.

  • mikeytown2 committed 3d45558 on 7.x-2.x
    Issue #2657894 by mikeytown2: Fix issue with moving css/js added to the...
mikeytown2’s picture

Yet another fix... issue isn't easy

Status: Fixed » Closed (fixed)

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