I'm using a lot of javascript files for my articles. These scripts shouldn't be loaded everywhere - only in certain articles. That's the reason why I don't add them inside of the templates´ head. At the moment I've included them directly inside the article.

Do I have any disadvantages (regarding SEO) when these scripts aren't placed in Joomla's header?

What is the best solution to place article specific scripts inside the header area?

  • Welcome to JSE. Please take our tour.
    – mickmackusa
    Jul 24, 2021 at 21:58

1 Answer 1


You could add a script (or CSS) to the doc head using the HTML Helper

use Joomla\CMS\HTML\HTMLHelper;

HTMLHelper::_('script', 'path/to/your/js/script.js', 
['version' => 'auto', 'relative' => false]

However, you cannot add PHP code to Joomla articles so you have to use another method for that. For instance a plugin that adds it to the code for certain articles (article IDs).

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.