Skip to main content
Home
Drupal 8 add inline JavaScript to a page

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.

superuserTue, 18/02/2020 - 12:06
  • Read more about Drupal 8 add inline JavaScript to a page
https://www.aram.cz/article/drupal-8-add-inline-javascript-page

© Shivakumar Ramamurthy