How can I add external javascript to aggregation? What wrong I may be doing? Is there any other way?

I tried following in template.php with no luck

function _phptemplate_variables($hook, $vars) {
  if ($hook == 'page') {
    // Add the script.js file
    drupal_add_js(path_to_theme() .'/gn.js');
    // Reload the scripts variable to include the added file
    $vars['scripts'] = drupal_get_js();
    if(module_exists('javascript_aggregator') && $vars['scripts']) {
      $vars['scripts'] = javascript_aggregator_cache($vars['scripts']);
    }

    return $vars;
  }
  return array();
}

Comments

robloach’s picture

You might want to take part in the discussion for Drupal 7: #91250: JavaScript Patch #4: External Scripts.

The easiest way with the JavaScript Aggregator to do this would be to stick it in your file system somewhere, and then have your module add it to the page using drupal_add_js(). In Drupal 7, it should have core support.

derjochenmeyer’s picture

derjochenmeyer’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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