I used to believe that you should not insert javascript blocks
<script language="javascript">
<!--
//-->
</script>
into the body part of a (what, HTML, XHTML?) document, but rather into the head.
But is that still true?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Script in the body (not links to external files) is like putting CSS in the head–people move toward separating it so that they can have the markup and logic separate for clarity and ease of maintenance.
I’m a big fan of the document ready feature of Jquery…but that’s just personal preference. A dom loader is really the only way to guarantee loading is going to be identical between the various different browsers. Thanks, Microsoft!
I say use common sense…it’s not worth doing another file for a single line of code…or even two. If we all went to the extremes that best practices sometimes ask us to go, we’d all be nuts…..or at least more nuts than we are now.