I am trying to add an external JavaScript file to my site using hook_preprocess_page()
.
In Drupal 7, I used drupal_add_js()
.
function mymodule_preprocess_page(&$vars) {
$uuid = trim(variable_get('variable_id', ''));
drupal_add_js('//cdn.cookielaw.org/consent/'.$uuid.'.js', array(
'type' => 'external',
'scope' => 'header',
'group' => JS_THEME,
'every_page' => TRUE,
'weight' => -1,
));
}
What function/method should I use in Drupal 8?