Infrequently Noted

Alex Russell on browsers, standards, and the process of progress.

An Now For Something Entire....Oooh! Shiny!

The Google O3D team just launched and the news stories are already starting to trickle out.

Ok, so it's shiny...but so what?

First, O3D embeds V8. This means that while you might be running your O3D code in a browser with a terrible JavaScript engine, or worse, an engine with terrible GC pauses, your O3D content isn't subject to those problems. This is a Big Win (TM). Most of the web can limp by with bad GC behavior, but interactive 3D just can't. You might have seen the difference this makes by running Dean's Monster demo in Chrome and then trying it in other browsers.

Next, O3D presents a scene graph. Direct-mode proposals to the 3D-on-the-web discussion are based on the idea that JavaScript programmers will ship enormous toolsets down the wire in order to re-create the scene graph and/or to parse shape descriptions. Having direct access to the OpenGL surface description is incredibly powerful, but I suspect not sufficient in the long term to really bootstrap a world where 3D is a first-class citizen. Also, using the web as a way to break-open some of the closed interchange challenges of today's 3D world isn't going to happen when everyone's description of things is entirely programmatic, so I'm excited by the direction of O3D as a force for good.

Congrats to the O3D team. It's a big day for them and the deserve huge props for shipping concurrently on Windows and Mac.

Ending The ga.js Wait

Google Analytics is ubiquitous, not least of all because it's better at what it does than most of the alternatives. Also, it doesn't require any install or maintenance. And it's free. What's not to like?

Frankly, not much, but if I had to nit pick, I'd note that the worst part of Google Analytics is the ga.js script that does the actual tracking of content. It's not bad, in and of itself, but it tends to load slowly. There are several reasons for this:

So how to fix this? Dojo 1.3's dojox.analytics.Urchin to the rescue! Given that I was going to be including Dojo on the page to do other things anyway, I can use 1.3's new Urchin system to help amortize the cost of using Google Analytics. The code running on this blog now includes the following code (more or less):

<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/dojo/1.3/dojo/dojo.xd.js">

</script>
<script type="text/javascript">
dojo.addOnLoad(function(){
setTimeout(function(){
dojo.require("dojox.analytics.Urchin");
dojo.addOnLoad(function(){
var tracker = new dojox.analytics.Urchin({
acct: "UA-XXXXXX-X" // your tracking # here
});
});
}, 100);
});
</script>

You can see the real thing by looking at the bottom of this page which pulls in custom.js which includes this logic. Pete Higgins blogged about how the module works when he first wrote it, and the strategy is to load Dojo from a CDN (since the page wanted it for other things) and wait until after the page has loaded to include ga.js. This delayed loading ensures that the page is responsive before we start doing anything related to tracking. The nested calls to dojo.addOnLoad show how we can wait for one set of modules to finish before kicking off another group, and in this case we also wait until after the page is responsive to load dojox.analytics.Urchin. This module further delays loading of ga.js, meaning that it doesn't matter how long it takes for things like DNS to resolve and for Google to serve ga.ja since it's not ever blocking the user.

Looking at the "before" and "after" shots in firebug gives you some idea of how this technique can really make a difference:

[caption id="attachment_940" align="aligncenter" width="300" caption="onload waits for ga.js"]onload waits for ga.js[/caption]

[caption id="attachment_941" align="aligncenter" width="300" caption="using dojox.analytics.Urchin, we can get a responsive page and then track usage"]using dojox.analytics.Urchin, we can get a responsive page and *then* track usage[/caption]

We get page tracking and the user gets an interactive page faster. Rad.

Older Posts

Newer Posts