Javascript

bigdave

Well-Known Member
I've got a free(ish) day today so I thought it might be a nice idea to start looking at javascript. I'm using W3School as a starting point but 1 chapter in, I'm already coming across questions that the site doesn't seem to answer.

Can anyone explain the difference/benefits/disadvantages of javascript in the head, body and external files. I know there must be instances where the different methods of implementing script are necessary but W3School doesn't seem to go into any kind of detail as to what those are.


*EDIT*

I'm assuming that external .js is useful in the same way as external stylesheets in that one file can manipulate an entire site rather than just individual pages.
 
An external file can be included on any page so is better than embedding the same code on every page. It saves repetition and file size. It makes sense, yes like css files.

Javascript that goes on the page should just be specific to that page.

If you have javascript include files in the header they will load before the page loads, and if they are large they will slow the page loading. Page speed is a factor in Google's search algorithm. It is suggested that you include them at the end of the HTML document, so the page is viewable quicker.
 
Back
Top