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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Why do javascript files get inserted before </body> and not within <head>


Go to End


3 Posts   1967 Views

Avatar
vwd

Community Member, 166 Posts

28 March 2011 at 6:28pm

Hi,

Just wondering why javascript files included using

Requirements::javascript('...')
get inserted before
</body>
and not in
<head>
.

Just curious if there are any advantages of one method over the other.

Thanks.
VWD

Avatar
Nathan Cox

Community Member, 99 Posts

28 March 2011 at 8:47pm

It's considered best practice: putting the .js files at the bottom of the page makes them download last which increases overall page loading speed. Check out http://developer.yahoo.com/performance/rules.html#js_bottom

Avatar
vwd

Community Member, 166 Posts

28 March 2011 at 10:45pm

Great - thanks very much for that Nathan. I understand now.

VWD.