Use hook_page_build() instead of hook_init() to add JS to every page. The reason is that hook_init() runs on every request that goes to Drupal (AJAX requests, private file requests, boost / varnish requests etc.), but hook_page_build() runs only when delivering HTML.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

artematem created an issue. See original summary.

artematem’s picture

artematem’s picture

Status: Active » Needs work