Why does $page['content']['#attached']['js'] works , while $page['#attached']['js'] does not? Trying to attach js by means of #attached by means of hook_page_alter (see https://drupal.stackexchange.com/questions/171918/how-to-add-javascript-with-attached-and-hook-page-alter), I found that the following code 

      

 function MODULE_page_alter(&amp;$page) {
  $my_path = drupal_get_path('module', 'MODULE' );
  $page ['content']['#attached']['js'][] = array(
    'js' =&gt; array(
    'type'=&gt;'file',
    'data' =&gt; $my_path . '/module_test.js'),
  );
}


works properly - it attaches the file - while    

function MODULE_page_alter(&amp;$page) {
  $my_path = drupal_get_path('module', 'MODULE' );
  $page ['#attached']['js'][] = array(
    'js' =&gt; array(
    'type'=&gt;'file',
    'data' =&gt; $my_path . '/module_test.js'),
  );
}


does not. Why is it so?
For #attached elements to be processed, the array needs to be run through drupal_render(). That never happens for the $page array.

Parts of it are rendered, e.g. in page.tpl.php:

&lt;?php print render($page['content']); ?&gt;


But never the $page array itself.