2 January 2014

Use hook_page_build() instead of hook_init() to add CSS or 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.

Source code viewer
  1. /**
  2.  * Implements hook_page_build().
  3.  */
  4. function hook_page_build(&$page) {
  5. }
Programming Language: PHP