Placing scripts in the <head> makes sure that any functions are loaded before the buttons, links or other things that call them are loaded. If you put your scripts at the very end of a page, it is possible that a user already sees part of the page including a button with a JavaScript function call, while the rest of the page hasn't loaded yet. Result: user pushes button and gets JavaScript Error Message Alerts, because the browser can't find the script (yet).
Unless there's a good reason to do otherwise, place your scripts in the <head> .
Hiç yorum yok:
Yorum Gönder