How to know when you've a javascript in drupal

One problem in drupal 6 with javascript is when you add configuration to jquery in function and this function is called two or more times. Instead of overwrite the configuration, drupal creates an array with the same configuration. One way to known if you added more than once your configuration is:

 

  $js = drupal_add_js(NULL, NULL);
  $found = FALSE;

  if (!empty($js['setting'])) {
    foreach ($js['setting'] as $key => $value) {
      if (isset($value['example'])) {
        $found = TRUE;
      }
    }
  }

  if (!$found) {
    drupal_add_js(array('example' => array('lorem')), 'setting');

  }

Add new comment

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.