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:

Template Questions /

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

Javascript goes to the wrong place in the body

Go to End

3 Posts   925 Views


Community Member, 6 Posts

25 January 2014 at 3:31am

Javascript should be included at the bottom of the page. For me, it gets included at an aribrary place in the page. This is wrong, and it breaks the javascript. In Requirements.php it says:

// If your template already has script tags in the body, then we put our script 
// tags just before those. Otherwise, we put it at the bottom.

Javascript should go to the bottom! Always!

There may well be a google analyitcs script, which is required to go to the top of the body. If I have that, then how to hell do I get script to the bottom??


Community Member, 187 Posts

25 January 2014 at 4:08am

Hi thany,

This has been documented and fixed ( and the ability to force JS requirements to the end of your HTML will be included in the next SilverStripe release (3.1.3).



Community Member, 6 Posts

25 January 2014 at 4:15am

I just changed the Requirement.php to look for a special tag in the HTML, so at least it will work for me. I made it look for "<javascriptIncludeSpot>". Could be anything, but it works like a charm. It's much better than looking for the </body> tag, because it is optional.