You can place the script in the head or body as you like. The
script will behave as if it was located exactly where you put the
script tag in the document.
Peter’s comment indicates he feels ‘were’ is the preferred phrasing, and so do I.
‘behave as if it were’ is meant to indicate it is counter-factual (substitute ‘even though it’s not’) so the subjunctive should be used.
Also it just sounds better that way to me.