Welcome to WebmasterWorld Guest from 184.108.40.206
Forum Moderators: open
As you can see my scripts are in a js folder. Does the fact that I need to move back and forth between folders cause issues with speed?
And then my main concern/question:
Does is matter where I do above references? I.E. Just above </body> tag or just above </head> tag. OR..... is this a stupid question as it depends entirely what the js does. I.E. does it need to load first or last in order for the page to work/display properly.
Does the fact that I need to move back and forth between folders cause issues with speed?
Speed issue? No. This is the norm. (If there is any issue with resolving file references it is surely negligible?!) You are not really moving back and forth between folders, the 'current' folder is not changing. "../js/js_bbs.js" is a direct file reference, I see no problem with it.
Does is matter where I do above references? I.E. Just above </body> tag or just above </head> tag....
Preferably within the <head>..</head> section. In fact I would always try to reference your JS files here and write your code accordingly - unless there is a problem that prevents you from doing this. (See some later comments in this thread... [webmasterworld.com...] )
But, yes, JS files can be 'referenced' anywhere within your <body>..</body> element too.
[edited by: jatar_k at 3:05 pm (utc) on April 2, 2007]
[edit reason] fixed link [/edit]
I have not yet made my own decision as to whether or not this is a valid argument.
<script type.... src.... defer></script>
The browser then won't wait for this file to load before it continues with the page, however......
a) make sure nothing on the page is dependant on it, I usually have a few scripts sharing common funtions, so I include a common.js and then defer everything else. If a dependency is missing it'll throw an error as I'm sure you're aware.
b) same goes if you're calling the script in the body somwhere.
c) The window.onload event still won't fire until this file has loaded, or timed out trying.
In that case I would put the script tag at the end of the body, probably safest bet, unless script is on the same server in which case it would do well to fail to load id.
Thanks for the heads up Fotiman.