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.

Template Questions /

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

Setting order of Javascript in templates

Go to End

2 Posts   816 Views

Liquid Edge Creative

Community Member, 53 Posts

11 October 2012 at 9:56am

Hey family,

I'm having trouble getting some javascript to run in one of my templates. If I add the following to the top of my template, the associated Javascript is called in the head of the rendered page but the slideshow fails to work:

<% require javascript(mysite/javascript/fadeslideshow.js) %>

However if I add it to the head section of the template, it works fine.

I also have the following in my template:

<% require javascript( %>

On checking the source code of the rendered pages, I see that the slideshow works when fadeslideshow.js is positioned after the jquery.min.js, but fails when it is positioned before it.

So, how can I force Silverstripe to position the script in before the script in


Community Member, 9 Posts

4 November 2012 at 3:11am

Hi there!

Except when you're using the Layout folder, I don't think .ss-files are inheriting when they are on the same level.
Same for modules, the'll just be overwriting (I think).

I think it might also be a better approach to load your javascript at the bottom of your site instead of in the header.
Then I don't really get your question. So you want to put the script of before the one of,
although they don't inherit anything, at least not implicit? So unless you're using the Layout folder, I don't think this really matters.
You should just look at one .ss at a time and make sure the jquery is before the other scripts that are using it.

Did this help you in any possible way? Otherwise you should describe the problem with some more details cause I don't really get it :).