Placing JavaScript in the main tag can slow down page loading time, as JS needs to be parsed, processed, and executed (and possibly loaded if they are external files) before rendering the DOM. Even the use of "defer" does not actually allow this to be avoided - some browsers ignore the directive, and those that pay attention do not fully implement it, as you expected.
Placing JS at the bottom of the page is a great way to get quick wins with obvious page load times, and it also encourages proper SoC and progressive improvement, making it a little harder to encode incorrectly.
source
share