I am just beginning to learn JavaScript. I am following the book "Simply JavaScript" purchased from sitepoint. I just started the DOM and am trying to
write code for counting the elements in a webpage.

The count of the elements is always displayed as zero even though it's not true.
I am writing the code in an external file and linked it to the web page.

The code is working fine if i place it as inline in the webpage itself. How should i tell the browser to load HTML first and JavaScript later?

Thank You,