This question already has an answer here:

I develop a joomla system plugin and add some scripts by this way:

public function __construct(&$subject, $config)
    parent::__construct($subject, $config);

    $doc = JFactory::getDocument();
            $doc->addScript( JURI::base() . 'plugins/system/thebestcheck/js/thebestscripts.js' );


This works, but my js file is loaded above of jQuery standard file, how can I move it below if standard jquery?

enter image description here

marked as duplicate by fruppel, TryHarder, Lodder, Farahmand, johanpw Oct 28 '15 at 14:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Why don't you use a plugin event that loads the JS file after the head has been loaded – Lodder Oct 27 '15 at 20:36
  • Which event is it? I tested more events but always the same problem. – jExchange Oct 27 '15 at 20:59

You need to add JHtml::_('bootstrap.framework') or JHtml::('jQuery.framework') above the line addScript line.

Whenever we are creating custom extensions then we must include dependencies.By using this, it will automatically set proper ordering as you want. For more details kindly refer the following link: https://docs.joomla.org/Adding_JavaScript

Best Regards, Ruchika


call JHtml::_('jquery.framework'); before your $doc = ... line

  • 3
    although this line of code may solve the problem, it's good to include some explanations. – FFrewin Oct 27 '15 at 23:00

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