Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

linked javascript order

Go to End

3 Posts   2674 Views


Community Member, 89 Posts

14 April 2009 at 5:42am


in what order does ss link javascript files?
because in my i have:

<% require javascript(xxx/jquery-1.3.2.min.js) %>
<% require javascript(xxx/ui.accordion.js) %>

but when i test the page, ui.accordion.js is always linked bevor jquery...



Community Member, 15 Posts

28 July 2009 at 1:18pm

Can anyone provide insight into this? I'm having a problem with the javascript load order as well. I put my <% require javascript %> tag in my .ss file just before I need the functionality, but the included js file is being linked too early (it's being linked before jquery, which it depends on). So I can't use the library because it consistently loads before jquery.js.


Community Member, 15 Posts

29 July 2009 at 12:57pm

Edited: 06/08/2009 12:05pm

For the benefit of anyone else who has this problem:

Don't link to the javascript files from your templates. Instead, load them in the init() call in the relevant controller. For example:

public function init()

That works for me, as now jquery is linked before the other libraries that depend on it.

UPDATE: This is not an all-purpose solution. This fixed one particular situation, but doesn't truly solve the underlying problem. If anyone can shed light on how to really control the load order it would be helpful.