I know it has been discussed here several times, but:
Is there a way to include conditional JS from CDN in the head section?
My goal is to somehow use drupal_add_js, external. That will stick in the head area, even if I move scripts to the bottom of the page. It is about html5shiv and respond.js
The classic way to add js was discussed here and here. So what I've managed so far is to bring
<?php
function THEMENAME_preprocess_html(&$variables) {
drupal_add_js('https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.js', 'external');
drupal_add_js('https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js', 'external');
}
The problem is conditional. One way to add conditional elements, with drupal_add_js. I know how to load local conditional js, using a variable I'm creaing in template.php, like so:
<?php
$html5shiv = array(
'#tag' => 'script',
'#attributes' => array(
'src' => file_create_url(drupal_get_path('theme', 'THEMENAME') . '/js/html5shiv.js'),
),
'#prefix' => '<!--[if lte IE 9]>',
'#suffix' => '</script><![endif]-->'
);
drupal_add_html_head($html5shiv, 'html5shiv');
But this will only put the conditional JS even before the meta title element and I need this to be loaded at the end of my section, JUST BEFORE my scripts loaded from theme.info (scripts[] = js/main.js). And of course, this will load local JS, not external.
Any ideas?