Best place to include javascript in a field formatter? I've created a custom field formatter using hook_field_formatter_info() and implemented it using hook_field_formatter_view().

My formatter requires additional javascript though and at the moment I'm including it in hook_field_formatter_view() but I have a feeling there's gotta be a better place to do this.

However there is no hook_field_formatter_preprocess() (there is a formatter_prepare_view() though but it doesnt't seem right)

Any ideas?
Adding the JavaScript in hook_field_formatter_view() works just fine. Just also be sure to use #attached and not drupal_add_js() since that way your file is included in the render cache.

function mymodule_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  $settings = $display['settings'];

  foreach ($items as $delta =&gt; $item) {
    $element[$delta] = // Blah blah blah add output for each $items in $element as a render array.
  }

  // Add the JavaScript file.
  $element['#attached']['js'][] = drupal_get_path('module', 'mymodule') . '/mymodule.field.js;

  return $element;
}