Adding JS to region other then header or footer

It is said here in docs api you can add JS file to some other region then header of footer https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal…
To to that you need to assign it to that region but also add it in html/page preprocess

function my_module_preprocess_page(&$variables) {
    drupal_add_js(drupal_get_path('module', 'my_module') . '/includes/some.js', array(
      'type' => 'file',
      'scope' => 'region_scripts',
      'weight' => 50,
    ));

 $variables['scripts'] = drupal_get_js();
}
/**
* Implements hook_process_html().
*/
function my_module_process_html(&$vars) {
$vars['region_scripts'] = drupal_get_js('region_scripts');
}

This above can also be done in theme, both on page and html layer (process and preprocess)