Jump to:

23493 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » linked javascript order

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

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

Page: 1
Go to End
Author Topic: 2162 Views
  • marcink
    Community Member
    89 Posts

    linked javascript order Link to this post


    in what order does ss link javascript files?
    because in my page.ss 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...


  • dfondente
    Community Member
    15 Posts

    Re: linked javascript order Link to this post

    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.

  • dfondente
    Community Member
    15 Posts

    Re: linked javascript order Link to this post

    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.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.