Dorem - Jérémie Bouillon wrote:
On 01/05/2011 13:31, Krinkle wrote:
Just out of curiousity, to avoid or perhaps solve
a less-than-ideal
construction,
why does it have to be at the end per se ? What is it you want to
insert
there ?
Two things. First, I'm starting to seriously use MW, so it helps me
learning it :-)
Second in this specific case, it's for Google Analytics. Since they
have
changed it to a faster and asynchronous javascript handling, there's
no
extension with the appropriate code anymore, and they strongly
advise to
place it here (last thing before /head).
I'll adjust the code position in the future with more test and
feedback
when my site goes public, but right now I don't see the harm in
following their recommendation, and perhaps more important to have the
same result across the various part of my site (hence, having it
placed
on the same spot).
The Google Analytics script doesn't rely on any other resources. The
order/
/position of the script inside the <head> (or <body>) doesn't matter.
Google however likes to keep things simple for users to avoid
complication.
They recommend placing it right before </head>, that way everybody
knows where it must go, even for users who have little to no clue about
HTML and the Document Object Model.
I'm pretty sure it doesn't make any difference where you add it in your
document as long as it's parsed by the browser.
If you look at other scripts from google they sometimes say "inside
<head>",
sometimes "at the end of <body>" or "right before </head>"
or ".. </
body>".
It's just a way to simplify it for the users. It doesn't have to be at
the very
end of beginning of a tag, nor should it matter whether it's in <head>
or
<body>.
Add it somewhere and see if it works. If it does, you're doing it
Right ;-)
--
Krinkle