Me, and I'm sure many other developers, are used to writing smaller, inline script blocks in then <head>
tag, or in '' tags in view pages. Now my head looks like this,
<head>
<title>Simple Demo</title>
<script>
function setCheckCheckboxState(checkbox, state) {
}
$(function() {
$("#tri-state").prop("indeterminate", true);
});
</script>
</head>
And although the code runs fine for some reason, in the Chrome developer console, just above the $(function()
call, I get the error Uncaught ReferenceError: $ is not defined
Now I don't like seeing errors that have no bearing on my code while trying to debug that code, so I have moved the @Scripts.Render("~/bundles/jquery")
into the <head>
tag. Why should MS have moved it to after the body, when we all have access to an almost instinctive function that we use to only call any jQuery code once the whole document has loaded anyway?
` tag. http://stackoverflow.com/questions/436411/where-is-the-best-place-to-put-script-tags-in-html-markup
– Ray Cheng Mar 03 '13 at 07:02