I've got to say. this has been one weird thread to find. almost like a soap opera.
Anyway, Glen, did you ever get clarification on the question you posed below? Is there a recommendation going around that js scripts should be placed as late in the body as possible? Rick From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Glen Lipka Sent: Friday, August 24, 2007 8:43 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: jQuery's Fearless Leader on Ajaxian This one threw me. <script src=filename .js> tags should be placed as late in the body as possible. This reduces the effects of delays imposed by script loading on other page components. There is no need to use the language or type attributes. It is the server, not the script tag, that determines the MIME type. Does that mean that everyone who calls .js files should do it at the end of the body and not at the top in the head? No one does this now. Glen On 8/24/07, Pops <[EMAIL PROTECTED]> wrote: On Aug 24, 3:50 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote: > > From: Pops > > <snipped all the stuff I agree with :-)> > > Before I forget, Hector, in the future could you start a new thread for a > new topic like this? (And don't just change the subject line - start a new > message.) Ok, I will make it an effort to live the same "topic rules" we also impose in our own support forums. But frankly, I must say, you are beginning to annoy me with your not once, not twice, not three, but now the forth time you are in one way or another moderating or pointing out some silly thing to me. The decision to change topics is highly subjective, but yes, I know better to do it the appropiate time. I just didn't and it also cross my mind that someone else might do it depending on deep it got. So please stop. Its annoying. > Not a biggie, and I've "hijacked" threads myself, but starting a new thread > helps people follow the conversations. Sure, but believe it or not, the odds are extremely high I've been cyberspacing far longer than you, maybe not, nonetheless, I know everything there is about it. I've been developing mail products (at all levels) since the 80s and you not going to find many people out that match my credentials in this area. So I don't need to be told how to behave. Like you said, you couldn't changed it yourself the first time - but didn't for your own subjective reasons. Again, stop. Its annoying. Change the topic is fine, making a comment is not. I use to be just as anal, but I mellowed out. You should too. :-) > Actually, JavaScript *does* support local scoping, it just doesn't do it at > every curly brace. Every nested function has its own local scope, and you > can use an inline anynomous function to introduce a local scope anywhere you > want: Not the same. You modularized the code, thus creating a new function stack prolog and epilog. > > It is good practice to get use to the ideal of always > > initializing your variables. Many languages, especially > > those like JavaScript with RTEs (Run Time Engines), which > > typically automatically zero out all memory variables. > > JavaScript initializes all variables to the "undefined" value, whose type is > "undefined". I believe you nean undefined not the string "undefined." which is internal constant for null which in most language is a zero value concept. In other words, if you expected to be null, this is to common practice: var i; if (i == 0) alert("i is zerol"); // false if (i == null) alert("i is null"); // true if (i == undefinedl) alert("i is undefinedl"); // true if (i == 'undefined'l) alert("i is 'undefined'"); // false which is correct, Most RTEs will load low (zero out). Some systems will even load high, like a heap manager to help find leaks, overflows, underflows, etc, but when a uninitialized variable is referenced, it should be a null value. So its always better to initialize your variables, unless you specifically are designing for null. > > However from a programmer's system logic perspective: > > > var currentEntry = 0; // currently selected table entry > > > is "better" then > > > var currentEntry; // currently selected table entry > > Those are two different things. They both initialize currentEntry to > well-defined values. Neither one is better than the other, without knowing > more about the code that uses them. Of course, if you wanted a value: var currentEntry = 0; or a null: var currentEntry = null; either way, that is better. > You could, but why bother? I already know that "var currentEntry;" > initializes the variable to undefined (and if I don't know, I'd better > learn). Doing it explicitly doesn't add anything to my understanding of the > code. I disagree. Being specific is always terrific. The reason is if you get into the practice of not initializing, you might get into situations where you really don't know what the system is doing. Like I said, if a compiler is created for javascript, and the odds are very high we are headed in that direction, there is no doubt through practice, alot of these codes will be buggy as hell with all kinds of memory crash issues. Of course, the JS compiler writer would have to take real issue into account for the massive code out already there written with uninitialized variables. Initialize now, and you will have full confidence of your code behavior and others will gain more respect for the QA of your code as well. > I don't think so. There are a lot of basic coding principles that do carry > over to most languages, but you also need to take each language on its own. > In C, a variable will contain an unknown, arbitrary value if you don't > initialize it - not a good thing! In JavaScript, it will contain a specific > and well-defined value, the undefined value. I already pointed out a RTE or RTI will nearly always initialized its memory. Write a compiler for JS, like I have for few languages, and you will appreciate what I am talking about. > This particular thing is a pretty minor point, of course, but it's a good > example of where something that's important in one language may not matter > in another. I think the points being made transcent the language. Good coding practice in principles is across the board. > C, Java, and JavaScript make a fairly interesting case here, because their > syntax is so nearly identical but their semantics are so different. Mike, it doesn't matter what language you use. Coding guidelines are universal. If you ever did work for the governament, you would know the same rules of coding applied for any language being used. JavaScript to me, as I learn it more, its a blend of many languages. Only a handful provide you the option to not declare variables because it automatically does it for you at the first reference and usage. Like JS and some earlier BASIC models are examples dim J as integer K = 0 /// auio declared as in integer S = "Mike" // auto declared as a string That would be illegal in many BASIC compilers today, lilke our own but we do provide the option to use auto declaration for old timers. Strong type casting compilers and intepreters generally give you better QA, but some coders don't the like the tightnness. -- HLS