Navigator Dot CPU Class

04 Oct 2013

[1.30000000000000004 min read]

The other day people were sharing a link to a WebGL game that Microsoft made with Three.js, Hover. It’s pretty fun, you should try it out. It’s basically Duke Nukem meets Neopets. I think—I didn’t actually play it. Instead I jumped right into the JS source and ran into something I had never seen before: navigator.cpuClass.

b.arm = "arm" === window.navigator.cpuClass, b.arm
  && a("html").addClass("arm")

Just to be clear, the arm property is an expando on b, an HTMLCanvasElement:

var b = document.createElement("canvas");

So if navigator.cpuClass returns the string “arm”, add an “arm” class to the document element. ok.jpg

There’s a page on MSDN that defines cpuClass, which appears to be an IE-specific property. And I also learned navigator.oscpu is also a thing implemented in Gecko.

The good news is that WebKit and Blink browsers don’t implement either of these wacky interfaces.

Y’all, sniffing for CPU architecture on the web is weird.

So let’s not start using them now in 2013, deal? I have no idea what kind of optimizations the developers of Hover are trying to sneak in for Windows RT* tablets (or phones or whatever). But I think they’re probably doing it at the wrong abstraction level.

*Retweet *Realtime *Really Touchy *Radical Tablet *Nobody actually knows what RT means