4

I want to know how the jquery resources loaded into the Joomla Protostar Template under Joomla 3.3. If I look into the code I see the jquery resources are loaded but in the index.php I cant find any code line. Can anyone tell how the jquery resources are loaded?

2
  • 1
    Why a negative vote? Commented Aug 12, 2014 at 11:02
  • You now have the privilege to vote in our current moderator election. Please exercise your new democratic privilege. Commented May 6, 2021 at 4:54

2 Answers 2

4

jQuery automatically gets imported in noConflict mode when you use the following code:

JHtml::_('bootstrap.framework');

which also as you can probably figure out, loads the Bootstrap framework too.

You will see on line 38 of the index.php file in the Prosostar template folder

4
  • You can also change this to JHtml::_('jquery.framework'); if you do not want the bootstrap framework and just jquery. I think that is only in Joomla 3+ though but I could be wrong. Commented Aug 12, 2014 at 16:24
  • @Jordan, yes, you're correct. Only Joomla 3.x, but the Protostar template is part of Joomla 3.x so all is good :)
    – Lodder
    Commented Aug 12, 2014 at 18:25
  • Guess I will add, if you need to use jQuery use that code even if its being loaded somewhere else, it will only load once but if you add other scripts they will typically load above the framework unless it is above your scripts as well (mainly while using $doc->addScript($path)) Commented Aug 12, 2014 at 18:54
  • That's a whole new topic ;)
    – Lodder
    Commented Aug 12, 2014 at 18:57
2

In the section of my Protostar template I can see the following - can you not?

<script src="/media/jui/js/jquery.min.js" type="text/javascript"></script>
<script src="/media/jui/js/jquery-noconflict.js" type="text/javascript"></script>
<script src="/media/jui/js/jquery-migrate.min.js" type="text/javascript"></script>

There is also some documentation here that may help regarding Javascript frameworks and Joomla http://docs.joomla.org/J3.x:Javascript_Frameworks

See on line three;

To enable the Bootstrap framework, call JHtml::_('bootstrap.framework'). This will automatically enable the jQuery framework in noConflict mode (i.e. accessed via jQuery. instead of $.)

Hope this is clear and helps.

4
  • Yes, if you see in the html code then I can see this, but in the index.php the files are loaded from a different way Commented Aug 12, 2014 at 10:30
  • 1
    Ok, the answer was on the 3rd line of the documentation link I provided.
    – jonboy
    Commented Aug 12, 2014 at 10:43
  • I don’t understand the down vote because the answer is in the link you provide. I make a +1 and i suggest you add a quote from your link to your answer (« This will automatically enable the jQuery framework... ») Commented Aug 13, 2014 at 9:52
  • I also don't understand the down vote? Seems like a helpful answer - thanks Sébastien
    – jonboy
    Commented Aug 13, 2014 at 10:04

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.