It's not best practice to put the tag in the head section, but realistically it shouldn't cause a problem.
Originally, older browsers would render the head section before they created the body, so any javascript that referenced the body would fail. It would also, effectively, hold up the rendering of the rest of the page while the script ran.
As far as I know, all current browsers don't exhibit this behaviour so it should be fine. But make sure you test it before you put it live.
Connecting data systems since the 1980s.