In Drupal 7, I can use drupal_add_js within a theme's template.php file as a theme_preprocess_html(&$vars) function:
drupal_add_js(drupal_get_path('theme', 'mytheme') . '/js/scripts.js', array( 'group' => JS_THEME, 'preprocess' => TRUE, 'weight' => '999', )); $vars['scripts'] = drupal_get_js(); In Drupal 8, I've tried converting this using attached in my theme's .theme file as such:
$vars['#attached']['js'] = array( array( 'data' => drupal_get_path('theme', 'mytheme') . '/js/scripts.js', 'options' => array( 'group' => JS_THEME, 'preprocess' => TRUE, 'every_page' => TRUE, ), ), ); ... but that did not work and there were no errors in watchdog / console or otherwise.
According to the D8 API page for drupal_add_js:
Deprecated - as of Drupal 8.0. Use the #attached key in render arrays instead.
There was not much more info that that however. It seems that drupal_add_css will also use this method. I know it's still early days for Drupal 8 but I was hoping to get a jump on this.