| 12:20 am on Apr 2, 2007 (gmt 0)|
|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]
| 1:16 am on Apr 2, 2007 (gmt 0)|
I would suggest checking out the Javascipt tutorials on w3schools. One of the first lessons is where to put js.
| 3:42 pm on Apr 2, 2007 (gmt 0)|
It should be noted that there are some who feel the best place for the JS files is not in the head of your document, but instead as the last thing before the closing </body> tag. The reasoning behind this is that downloading of script files will block the content from being delivered, so putting it at the end allows all of the content to be delivered and rendered more quickly, and then your behavior gets loaded at the end. Presumably, this would give you faster rendering of your content.
I have not yet made my own decision as to whether or not this is a valid argument.
| 10:51 pm on Apr 3, 2007 (gmt 0)|
Add the defer parameter to your script tag, as follows:
<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.
| 3:00 pm on Apr 4, 2007 (gmt 0)|
This attribute was intended to alter the timing of component loading in pages. It is not well supported and should not be used (from what I've read).
[edited by: Fotiman at 3:05 pm (utc) on April 4, 2007]
| 6:40 pm on Apr 4, 2007 (gmt 0)|
Interesting point, I did a bit of Google, and found there is some confusion over the actual meaning of defer, which means some browsers treat it differently.
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.