Definition

drupal_add_js($file, $nocache = FALSE)
drupal-4-7/includes/common.inc, line 1248

Description

Add a JavaScript file to the output.

The first time this function is invoked per page request, it adds "misc/drupal.js" to the output. Other scripts depends on the 'killswitch' inside it.

Code

<?php
function drupal_add_js($file, $nocache = FALSE) {
  static $sent = array();

  $postfix = $nocache ? '?'. time() : '';
  if (!isset($sent['misc/drupal.js'])) {
    drupal_set_html_head('<script type="text/javascript" src="'. base_path() .'misc/drupal.js'. $postfix .'"></script>');
    $sent['misc/drupal.js'] = true;
  }
  if (!isset($sent[$file])) {
    drupal_set_html_head('<script type="text/javascript" src="'. check_url(base_path() . $file) . $postfix .'"></script>');
    $sent[$file] = true;
  }
}
?>