awebguynow said:
I've always thought a script tag to ref and ext JS file, should be
structured, like so
<script type="text/javascript" src="foo.js"></script>
This is technically an HTML question and not Java/ECMAscript. I would
advise you to follow what you consider the most authoritative standard or
specification you have. (Note that the W3 Consortium does not refer to
their "standards" or "specifications" as such, but more modestly refers to
them as "recommendations.")
When deciding who is authoritative in the event of a dispute, you might
consider who first originated the concepts involved in principle. But in
practice, reality shows that you will also make decisions based on the
usage of consensus.
I've noticed in some of the Venkman tutorials only use the "src"
attribute.
What is the best coding style ?
The developers of Venkman would probably not be considered even remotely
authoritative when it comes to writing HTML properly, and they would
probably not claim to be authoritative as well.
You could consider them authoritative when it comes to writing Javascript
debuggers however.
Also, I've done some event-driven JS programming (onEvent), but I've
also seen examples of <script> placed anywhere in an html file. I
think the whole html file is sent to the browswer, and JS called where
ever it is placed, but I am having calling a function in an external
file.
Script elements can be placed legally within the head and body of the HTML
document. The only thing that you have to keep in mind is that everything
is defined and objectified---the document content, the scripts---in the
order in which it is read, and reading is synchronous generally.
Thus if you make reference to (call, make use of) a variable or function
before the actual definition of that variable or function, expect an error
or exception. Note that variables or functions coded within the scope of
a function is not referencing or calling or making use of those variables
or functions when the function containing them is being defined.
When external JS file are "included" within an HTML document, it is
equivalent to inserting all their code at that place in the document where
the script elements are placed. Make sure they are relatively error-free
before moving their code to an external JS file: a single coding (not
runtime) error in some (maybe all) browsers effectively cancels all
variables and functions defined in that file as being part of the global
scope.
I plan on using Venkman more to debug, since I have no desire to get
MS's VS or MS Script Editor which comes with Office XP.
You should reconsider this if you intend that your scripts get widespread
use. The (horrible?) fact of life is that Internet Explorer is still the
giant in browser usage, and it differs from Mozilla/Firefox/real
Javascript browsers in only a small number of ways.
I do the heavy-lifting (initial code development) in Firefox with Venkman
and the Error2 console, as well as those extensions that display element
information right in the rendered page.
And then I set about to see how it runs in MSIE with the Script Debugger
handy and a battery of information about how to use ActiveX objects, if
needed.