I was wondering... what is the proper way to be adding jquery/js to a document? Currently, I'm doing this setup where I include the file (functions.js) right before the footer (I started doing this because I reverse engineered a website and just copied what they were doing). Then in functions.js, I just add
I think js/jquery loads faster this way than if you include the js right in the document, am I right?Code:jQuery(function($) { //jquery functions go here }
Another way I've seen is that people do some
orCode:document.ready(function() { } );
Sometimes it's in the <head>, sometimes it's above </body>.Code:window.load
Can anyone tell me if there is a right way or wrong way? For example, putting <script> right in the middle of <body> might not be considered right. I'm asking this because I'm not 100% sure what exactly I'm asking and how to describe it using a google search query. Thanks in advance, if you can decipher my gibberish.