If you have JS code which is intended to run as part of loading/building the page, where in the HTML should this go? For instance modifying a
Put them as functions in its own .js file which you include by at end of HTML or . If any of them needs to be executed during document load, call it using window.onload or whatever load function the JS library/framework offers, if you are using any.
As to the exact location, putting them in end of allows them to be downloaded before the HTML page is been shown in browser and putting them in end of allows the page to be shown a tad sooner because downloading the scripts will block the page rendering, thus it's a better speed experience.
However, IMO, it's a bit more robust to have the scripts downloaded before the page is rendered whenever you have some page elements which cannot be used without JS. In case of an impatient user this would otherwise lead to unusable elements.