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.

General Questions /

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

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

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


Reply


3 Posts   1035 Views

Avatar
vwd

Community Member, 159 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, 159 Posts

28 March 2011 at 10:45pm

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

VWD.