No, JS should always be executed in the body tag after all of the mark-up..
Like so:
HTML Code:
<!doctype html>
  <!-- title, meta, css, and *DOM-independent* JavaScript -->
  <!-- all mark-up for browser display -->
    //My *DOM-dependent* JavaScript.
*DOM-independent*: JavaScript that never references 'document' or conditionally checks if the document or parts of the document are loaded, and does not error if parts of the document are never loaded.
*DOM-dependent*: JavaScript that references the browser's 'document' variable or anything relating to the Document Object Model'

Since my example uses document.getElementsByClassName('class'), I am assuming there is an element with the class of 'class'. If used in the <head> section or anywhere before '<div class="class">' is seen (the browser reads from top to bottom), then it will be an empty list- as it wont see the elements if it is used before the elements are there.