Drupal 8 add inline JavaScript to a page superuserTue, 18/02/2020 - 12:06
Separate JS files are good but in certain cases (e.g. tracking scripts) it might be useful to just add a piece of inline code to a specific page.
This can easily be achieved from a custom module by implementing hook_page_attachments()
, checking the page you are on and adding the JS code to the HTML head.