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:

Upgrading SilverStripe /

Ask questions about upgrading SilverStripe to the latest version.

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

Javascript (mystery) includes after body

Go to End

3 Posts   3720 Views


Community Member, 44 Posts

20 December 2008 at 4:32am

Edited: 20/12/2008 4:34am

With a fresh 2.3.0-rc2 install, I'm seeing the javascripts that I call with the Requirements in the init included _after_ the BODY tag. It's really weird and I am lost as to what the problem is. Is someone else seeing this with 2.3.0-rc2 or is it a mistake on my part?

class HomePage_Controller extends Page_Controller {
	function init() {
			Requirements::javascript( "test/javascript/contentslider.js" );

The above results in the following in the source of our page:

<body><script type="text/javascript" src=""></script><script type="text/javascript" src=""></script><script type="text/javascript" src=""></script>


An it's not only in the wrong place, but I never asked for base.js and en_US.js to be included?


Forum Moderator, 5523 Posts

20 December 2008 at 2:12pm

The JS writing to the body is a speed improvement see it should write it to the bottom unless it detects that the script needs it before hand I think.

You can disable this feature and just include it via the head by setting this in your _config file Requirements::set_write_js_to_body(false);

As for en_US.js / base.js I'm pretty sure these are included as part of i18n SilverStripe support.


Community Member, 44 Posts

22 December 2008 at 11:17pm

Thank you for that! But it's still odd that the 2.3.0-rc2 is writing the Javascript right after the body tag, rather than to the end of it?

Anyway, I've posted this info on the requirements page in the docs. Thanks again!