how to add javascript with #attached and hook_page_alter
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(&amp;$page) {
  $my_path = drupal_get_path('module', 'MODULE' );
  $page ['content']['#attached']['js'][] = array(
    'type'=&gt;'file',
    'data' =&gt; $my_path . '/module_test.js'
  );
}