Load javascript in image_caption.info file instead of in hook_init(). It is not recommended implementing hook_init() for loading javascript and css.

https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func...

To add CSS or JS files that should be present on all pages, modules should not implement this hook, but declare these files in their .info file.

Comments

Елин Й. created an issue.