- JS load order with assets


I try to load my javascript files in the correct order. I need to load jquery-ui.js AFTER jquery.js is loaded. But no matter what I do, jquery-ui.js always gets loaded first.

'assets'  => array(
  'jquery' => array(
    array('javascript', 'js/jquery.js', array('position' => 'H'))
  'jquery/ui' => array(
    array('javascript', 'js/jquery-ui.js', array('position' => 'H')), 
    array('javascript-localized', '/ccm/assets/localization/jquery/ui/js'),
    array('css', 'css/jquery-ui.css', array('minify' => false))

I cannot set the the position of jquery-ui.js to "F" so it loads in the footer. Jquery UI tooltip has a problem with bootstraps tooltip and I need also to load jquery-ui.js before bootstrap and if I place it in the footer it of course has the wrong order again and starts underneath bootstrap.

View Replies: View Best Answer
MrKDilkington replied on at Permalink Best Answer Reply
Hi Kiesel,

Are you requiring jQuery in your theme page_theme.php? If so, jQuery will load in the page <head>.

If this is for a block, you can require jQuery UI in your controller view() method.
public function view()
    // you cannot require just the jquery/ui JavaScript file, you must require the full jquery/ui asset group
    // - $this->requireAsset('js', 'jquery/ui'); does not work

- jquery-ui.css will load in the page head
<link href="/concrete5/concrete/css/jquery-ui.css" rel="stylesheet" type="text/css" media="all">

- jquery-ui.js will load at the end of the body
<script type="text/javascript" src="/concrete5/concrete/js/jquery-ui.js"></script>
<script type="text/javascript" src="http://localhost/concrete5/index.php/ccm/assets/localization/jquery/ui/js"></script>
Kiesel replied on at Permalink Reply
Thank you. I figured I have to make the call for them in the right order and not the registering.

I managed to get it working with loading it in a quirky way, but might try out your suggestion.

Anyways, thanks once more to taking yourself the time to help. It's much appreciated, especially as we all can see how much you help everyone out.