drupal_add_js only once I have a field which is used in a nodeblock, and only appears on a few select pages. This however will vary throughout the lifetime of the website so I've been looking for a way to insert the Javascript this field requires only when it's present. Additionally, the field can appear more than once on any given page.

Looking at drupal_add_js, I can't see that it provides a way to only include JS once. Using this I was hoping that I could just call it in the field--field-name.tpl.php file for that field but as it occurs multiple times, the JS is included more than once.

I've looked at the module JS Injector, but that's just page specific and just calls the aforementioned function. This wouldn't help me because every time a new block is added somewhere, the list of pages including the JS would also need to be updated.

Is there a way I can include a JS file just once in Drupal?
It depends what type of javascript you are adding. 


drupal_add_js will only add files once, no matter how often it's called ;
Settings would overwrite previous values, so it's not a major problem ;
Inline code would indeed get added multiple times.


Given that your script needs including only once no matter how often the field is present, I assume you are not generating it's code on the fly - so putting it in a file would be an option.

Otherwise, as suggested by Clive, you could have your own wrapper around drupal_add_js that ensures a given inline js is only added once by using a static variable.