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,
));
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | advagg-2657894-4-fix-move-css.patch | 1.09 KB | mikeytown2 |
Comments
Comment #2
mikeytown2 commentedThanks for the bug report with code! I'll take a look here in a little bit
Comment #3
mikeytown2 commentedLooks like I won't be able to get to this till tomorrow.
Comment #4
mikeytown2 commentedLooks like this functionality was broken when dns_prefetch was added. drupal_get_html_head() has been split up
Comment #7
mikeytown2 commentedCommitted this
http://cgit.drupalcode.org/advagg/commit/?id=c4bfc34
Omega theme was causing issues so I re-worked how the alter is done.
Comment #9
mikeytown2 commentedYet another fix... issue isn't easy