Just wondering how following happens, maybe someone knows:

Like known I remove unwanted Joomla scripts in common ways like using:

$this->_script = $this->_scripts = array();

or in single ways:


but I have a Joomla site were this has no effect nevertheless scripts were loaded. Also to get scripts via a second way has no success:

$document = JFactory::getDocument(); 
$headData = $document->getHeadData();
$scripts = $headData['scripts']; 

when I check scripts just before load in both cases scripts are empty and than of course cannot unset but they are loaded with the HeadRenderer of Joomla.

I can solve this with copy, edit and loading my own file based on: \libraries\src\Document\Renderer\Html\HeadRenderer.php

but I'm really interested what happens here, it doesn't matter if I load a custom template or use a Joomla (Protostar) one by only changing to unset scripts. Same problem scripts are empty via $this or getDocument(); but loaded in to the head html via <jdoc:include type="head" />

Somehow the scripts are not loaded during Template Rendering but with the HeadRendering? Tried with disable any third party modules and plugins but no change ... Big question mark for me? Any ideas?


  • Welcome to JSE, thank you for posting a comprehensive question -- I wish more questions here had so much effort/detail. While you wait for support please earn your JSE Informed badge and continue researching your issue. If you are able to self-solve, you are welcome to post an answer. Sep 17, 2018 at 21:24
  • I actually ran into the same issue, however it was only certain scripts that were not working, despite the path being correct. I ended up overriding those files and removing all the code. Are you using any 3rd party plugins that could potentially be caching it storing the scripts array to a session variable?
    – Lodder
    Sep 18, 2018 at 7:13
  • yes that was something I supposed too and gave it a try by disable the plugins but it couldn't fix th problem so far Sep 19, 2018 at 12:52

1 Answer 1


Using template to manipulate head data has never been correct. Instead you should use a system plugin with onBeforeCompileHead event.


  • yes thanks this is another option I had in mind for that issue but I was interested in the technical workflow how it happens that scripts are not loaded to the document object in the template ... Sep 19, 2018 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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