<head>. Unfortunately, there is one huge problem with this technique:
When a web browser renders an HTML document, it must first parse—and then load completely—the contents of the
<head> before it can show any content whatsoever!
<head>, you’re forcing web browsers to load those scripts entirely before serving any content to the user. Egregious, indeed.
So, what’s a webmaster to do? Follow the rule below to ensure proper JS positioning on your site.
<body> tag, but with two notable exceptions: Google Analytics and TypeKit scripts, which we’ll address separately.
Google Analytics tracking code
In 2010, Google introduced a new, asynchronous tracking code for Analytics users. Because this script loads asynchronously (and therefore does not affect the perceived page load time), it can be referenced from a different, perhaps more optimal, location in the HTML document.
For best results, Google recommends that you place this new, asynchronous tracking code just after the opening
<body> tag in your document.
TypeKit activation script
<head> to ensure that the font is available the second the browser serves content to the user.