Putting the script tag after the body tag is not correct according to the HTML standard, and there is hardly any reason to do so. A script tag should preferrably go inside the head
element, or inside the body
element if you have some specific reason for doing so.
You can put the script tag last in the body element instead of after it, with little or no difference on the functionality. All the elements in the document already exist at that point, so there is no normal reason to put it outside the body.
Putting the script tag outside the body will most likely work in all browsers, because they generally try hard to consider whatever HTML-ish mess you throw at them, but it doesn't follow the specification so there is no guarantee that all current browsers actually tolerate it, or that any future browsers do.
Also, there is a risk that invalid code like that will change how the browser interprets the entire HTML document. If the browser decides to parse the document in the backwards compatible quirks mode, it can have radical effects on the layout of the page.