Add conditional javascript from CDN (external library) 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

&lt;?php
function THEMENAME_preprocess_html(&amp;$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:

&lt;?php
$html5shiv = array(
    '#tag' =&gt; 'script',
    '#attributes' =&gt; array(
        'src' =&gt; file_create_url(drupal_get_path('theme', 'THEMENAME') . '/js/html5shiv.js'),
    ),
    '#prefix' =&gt; '&lt;!--[if lte IE 9]&gt;',
    '#suffix' =&gt; '&lt;/script&gt;&lt;![endif]--&gt;'
);
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?
The Boilerplate theme does it for CSS by adding to template.php in the theme:

function boilerplate_preprocess_html(&amp;$vars) {
  if (!module_exists('conditional_styles')) {
    boilerplate_add_conditional_styles();
  }
}

function boilerplate_add_conditional_styles() {
  // Make a list of base themes and the current theme.
  $themes = $GLOBALS['base_theme_info'];
  $themes[] = $GLOBALS['theme_info'];
  foreach (array_keys($themes) as $key) {
    $theme_path = dirname($themes[$key]-&gt;filename) . '/';
    if (isset($themes[$key]-&gt;info['stylesheets-conditional'])) {
      foreach (array_keys($themes[$key]-&gt;info['stylesheets-conditional']) as $condition) {
        foreach (array_keys($themes[$key]-&gt;info['stylesheets-conditional'][$condition]) as $media) {
          foreach ($themes[$key]-&gt;info['stylesheets-conditional'][$condition][$media] as $stylesheet) {
            // Add each conditional stylesheet.
            drupal_add_css(
              $theme_path . $stylesheet,
              array(
                'group' =&gt; CSS_THEME,
                'browsers' =&gt; array(
                  'IE' =&gt; $condition,
                  '!IE' =&gt; FALSE,
                ),
                'every_page' =&gt; TRUE,
              )
            );
          }
        }
      }
    }
  }
}


Then added to the .info file:

stylesheets-conditional[lte IE 8][all][]  = css/compiled/ie8.css
stylesheets-conditional[lte IE 7][all][]  = css/compiled/ie7.css
stylesheets-conditional[lte IE 6][all][]  = css/compiled/ie6.css


I'm sure this could be easily adjusted for JavaScript instead