Skip to main content
1 of 2
Dalmaz
  • 510
  • 4
  • 24

The code that finally got it included an important change with regard to @AyeshK 's answer. The [attached] is not put at the top level if $page , but inside ['content'] or ['header'].
The adapted code from the Format#1 is now:
function MODULE_page_alter(&$page) { $my_path = drupal_get_path('module', 'MODULE' ); $page ['content']['#attached']['js'][] = array( 'type'=>'file', 'data' => $my_path . '/module_test.js' ); }

Thank you @AyeshK and @Beebee for helping to sort this out.

Dalmaz
  • 510
  • 4
  • 24