Add JavaScript into a specific content type I would like to know what is the best way to add a JavaScript file into a specific page basing on the content type. For example, I want to add this:

&lt;script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false'&gt;&lt;/script&gt;


So far, what I have done is using this way to add into my specific content type. For the  map_page content type, I adde the below two line of code in page--map_page.tpl.php.

drupal_add_js("http://maps.google.com/maps/api/js?sensor=false", 'external');
$scripts = drupal_get_js();


Is there any other better way? if possible can give some example, currently not really understand well...
I can't comment on the proper Drupal 7 equivalent, but in Drupal 6 sites I do this in a template_preprocess_page.

I will have some logic to make the decision (either based on arg() or page_manager_get_current_page() from panels), and then prepend $vars["scripts"] with the external script.  I prepend so that I don't run into dependency trouble with any local scripts.

I will also sometimes set up a new region called $global_scripts for thinks like Google API and SWFObject that I want to load from a CDN, and this gets printed out before $scripts in the page template.

To be honest, though I normally have all JS on all pages so that the files get cached.