You get the `HtmlDocument' object:
$doc = JFactory::getDocument();
// echo "<br><pre>"; print_r($doc); echo "</pre>"; // to check what you have here
You can get only the head Data:
$headData = $doc->getHeadData();
$Title = $doc->getTitle();
You can set things:
$doc->setHeadData(array $data);
$doc->setTitle('my title');
And you can see all of the things you can do in this class here:
https://api.joomla.org/cms-3/classes/Joomla.CMS.Document.HtmlDocument.html
and here: https://api.joomla.org/cms-3/classes/Joomla.CMS.Document.Document.html
EDIT:
On the updated part of your question: In Joomla you do not really have to know which extension is adding a script in the head as far as deleting that script does not cause problems. And as I see in your case you are determined to delete that script from the <head>
of your site. I also do not know your expert level of PHP and Joomla thus I'd like to provide you two approaches here.
First the simplest and a bit hacky solution which is not recommended by more serious Joomla developers and the reason it is not recommended is mainly because you will write few lines directly in your template's index.php
file. If the template will be updated, your few lines of added code is going to be deleted too by the template update. But maybe you at the moment do not care about this and after the occurent template update you can still copy these few lines back in the index.php
file again if you would like to.
So, place these few lines of PHP code in your template's index.php
file right after the line: <jdoc:include type="head" />
:
if (isset($this->_scripts['/media/system/js/html5fallback.js'])) {
unset($this->_scripts['/media/system/js/html5fallback.js']);
}
This will delete the unwanted script loading in the <head>
.
Now, the second and standard Joomla solution for these kind of tasks is creating a Joomla system plugin on the event: 'onBeforeCompileHead'
which event is triggered in the HeadRenderer.php file in Joomla which does what it's name suggests. (file location in Joomla: libraries/src/Document/Renderer/Html/HeadRenderer.php
)
Since few weeks ago someone here has given a good example of this kind of plugin, I'll not repeat the code example of that plugin as it is quite self explanatory after a short time of studying these two posts here:
The system plugin example: onAfterRender plugin only triggers on backend
And the plugin code part here in this post's answer which you should use in your plugin and you can delete anything from the head with using this or something very similar plugin code:
How can I completely remove Bootstrap from the frontend of Joomla?
I copy here the meat of this plugin though:
class plgSystemYourPlugin extends JPlugin
{
public function onBeforeCompileHead()
{
$doc = JFactory::getDocument();
// Remove the unwanted script
if (isset($doc->_scripts['/media/system/js/html5fallback.js'])) {
unset($doc->_scripts['/media/system/js/html5fallback.js']);
}
}
}
This plugin can be written very fast actually and if you would like to create one, you can study the subject more here: https://docs.joomla.org/J3.x:Creating_a_Plugin_for_Joomla
I hope the above will help you more.
<head>
?