HTML and CSS Reference
In-Depth Information
SCRIPT: AT THE TOP OR AT THE BOTTOM?
It is important to note that the
script
and
style
elements do not need to appear in
the head of the HTML document; in fact, the Yahoo! Developer Network published a
list of 35 best practices for performance gains that stated the
script
element should
be placed at the bottom of the web page (see
http://developer.yahoo.com/
at the top, in the head area.) Additionally, the HTML5 Boilerplate (
ht-
tp://html5boilerplate.com
)
mentioned in
Chapter 1
places all scripts (ex-
cept Modernizr, because it is needed earlier) at the bottom of the page, before the
closing
</body>
tag. Arguably this practice, while offering a performance boost,
has semantic issues, because it moves metadata about a page into the body area, in-
stead of the head where it belongs. Ideally as the
async
and
defer
attributes gain
wider support, the location of the
script
element within a page will become a moot
point.
Lastly, the
noscript
element is for surrounding content that is shown only when
scripting is disabled or not supported in the browser. If the
noscript
element is placed
in the head of the document, it can contain only the
link
,
style
, and
meta
elements;
otherwise, if it is in the body, it can contain all the normal elements that would appear
in the
body
element, except another
noscript
element. It's also worth noting that the
Search WWH ::
Custom Search