</body> so that it is run after all the elements have been rendered.
However, if you organise your code correctly, the position on the page doesn’t matter.
For example, when using jQuery, you can ensure the code isn’t run until the page and its elements are fully rendered by doing the following:
Then the script reference can be put in the
Script tags should be referenced just before
</body>. This prevents render blocking while the scripts load and is much better for site perception speed.