7

When building a template, you must put one (and only one) of these calls inside your <head></head>:

<jdoc:include type="head" />

Checking here does not provide much extra info:

https://docs.joomla.org/Jdoc_statements#Head

So my question is: what exactly gets loaded in this call? I know this will load additional javascript and CSS files when using:

$document = JFactory::getDocument();
$document->addStyleSheet($url);
$document->addScript($url);

or custom tags using

$document = JFactory::getDocument();
$document->addCustomTag($stylelink);

Anything else? And is there a way to order what's loaded there?

Thanks.

1 Answer 1

2

In Joomla 3.x, <jdoc:include type="head" /> loads the following (in no particular order):

  • jQuery library
  • jQuery noConflict
  • jQuery migrate
  • Bootstrap library
  • MooTools library
  • All <meta> information
  • Any CSS and JS files for extensions on pages they're assigned to
  • Any CSS or JS declarations being used in extensions

Mootools gets loaded as there are still things in Joomla that require it. It will eventually get removed.

jQuery gets loaded because Bootstrap requires it and Joomla 3.x uses Bootstrap (unfortunately).

3
  • Hmmm... does it always load jQuery and Bootstrap? I've seen Protostar specifically loads that using JHtml::_('bootstrap.framework'); Why would it do so if it's loaded with jinclude? Thanks for your quick reply Commented Dec 4, 2014 at 11:52
  • It's a fallback. Some extensions such as com_content require it and any JHtml imports get pushed to the head
    – Lodder
    Commented Dec 4, 2014 at 12:09
  • Ok, I think I understand now: if jQuery/Bootstrap is called by any extension, then it's loaded by the <jdoc:include type=head>. But if 'nobody' calls them and you're going to need them, it's up to you to add the call in your extension. So, in the end, if you're going to need jQuery or bootstrap in your extension, you should add a JHtml::_('bootstrap.framework'); call in it, just in case it hasn't been loaded yet. Thanks a lot! Commented Dec 4, 2014 at 12:56

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.