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.

Upgrading SilverStripe

Ask questions about upgrading SilverStripe to the latest version.

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

Javascript (mystery) includes after body


3 Posts   2821 Views


20 December 2008 at 4:32am (Last edited: 20 December 2008 4:34am), Community Member, 42 Posts

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?


20 December 2008 at 2:12pm Forum Moderator, 5511 Posts

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.


22 December 2008 at 11:17pm Community Member, 42 Posts

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!