+4  A: 

You should place your analytics code at the bottom of the page so that everything else loads first. Other than that, I don't think there's much you can do.

edit: Actually, I just found this interesting blog post on a way to speed up analytics by hosting your own urchin.js file. Maybe it's worth a look.

Paolo Bergantino
Yes, I'm already doing that. You'll notice that the analytics and adsense loading is happening after the loading of the page itself.
Kevin Pang
A: 

Probably not anything you can do aside from putting those includes right before the closing body tag, if you haven't already. JavaScript includes block parallel HTTP requests which is why they should be kept out of <head>

Mark Hurd
inline script is also blocking, it's just that you won't always notice
annakata
+1  A: 

I've never seen anything like that using Firebug on Stack Overflow and we use Analytics as well.

I just ran a trace and I see the request for the

http://www.google-analytics.com/__utm.gif?...

Happening directly after the DOMContentLoaded event (the blue line). So I'd suspect the AdSense, first. Have you tried disabling that?

Jeff Atwood
You're right Jeff. The DOMContentLoaded event is happening way after the initial GET. I disabled both analytics AND adsense and the DOMContentLoaded event is still firing around 1 second...
Kevin Pang
To put some numbers on it, when hovering over the initial GET I get: 96ms Receiving Data, 736ms 'DOMContentLoaded' event, 778ms 'load' event
Kevin Pang
+1  A: 

As it goes, I happen to have rather heavily researched this just this week. Long story short, you are screwed. As others have said the best you can do is put it at the bottom of the list of requests and make the rest of your code depend on ready rather than onload events - jQuery is really good here. Some portion of the js is static, so you could clone that locally if you keep an eye on it for maintenance purposes.

The google code isn't quite as helpful as it could be in this area*, but it's their ballgame and anything you do to change it is going to be both complex and risky. In theory, wrapping with a non-blocking script call in the header is possible, but would be unlikely to gain you a benefit given the additional abstraction, and ultimately with adsense your payload is an html source, not script.

* it's possible google have a good reason, but nothing I can deduce from the code they expose

annakata
A: 

Surely Google's servers will be the fastest part of the loading, given that your ISP and most ISPs will have a local cache of the files too?

You could inject the script into the head on page load perhaps, but I'm not sure how that effects urchin.js.

Chris S
A: 

Could be that your page simply takes that long to parse? It seems nothing network-related is happening. It simply waits around a second before the adsense/analytics requests are even fired off. I don't suppose you have a few hundred tables on the page or something? ;)

jalf