Hi I am trying to move js from footer to header but I am getting exception like

Exception: Invalid JS asset type. in Drupal\Core\Asset\JsCollectionRenderer->render() (line 90 of D:\Users\myname\Sites\devdesktop\projectname\docroot\core\lib\Drupal\Core\Asset\JsCollectionRenderer.php).

Here is my code in .theme file. Please let me know where I am wrong

  function HOOK_js_alter(&$javascript, \Drupal\Core\Asset\AttachedAssetsInterface $assets) {
   $javascript['core/assets/vendor/jquery/jquery.min.js']['scope'] = 'header';
   $javascript['core/assets/vendor/jquery/jquery.min.js']['weight'] = '-20.1';
   $javascript['https://cdn.jsdelivr.net/npm/bootstrap@3.4.0/dist/js/bootstrap.js']['scope'] = 'header';
   $javascript['https://cdn.jsdelivr.net/npm/bootstrap@3.4.0/dist/js/bootstrap.js']['weight'] = '-20';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.