Saturday, May 25, 2013

Microdata: An Open Standard vs Efficiency

This isn't a major issue. I just thought I'd write about a question I'm working on.

Grimwire dev branch currently uses the Microdata standard to embed data into the interface. Because the items API is not implemented in enough browsers (chrome) Grimwire has to do attribute-based selector queries (which are slow) to manually form the item. This gets worse when dealing with embedded objects. It's not a huge problem, but it's not good. Chrome will probably (?) implement it later.

That said, Grimwire also uses data-uris to allow hrefs to indicate chunks of data. Calling local.http.dispatch({ url: 'data:text/plain,foobar' }); gets you back a status=200, Content-Type=text/plain, body="foobar" response. Embedding JSON as a data-uri would be more efficient than Microdata, and would allow httpl (the namespace targeting web workers) and http addresses to be used (realtime freshness).

Choosing between the open standard and something more specific is a hard choice. I try to only do the latter when I think I can make a case for other people to adopt the same standard. I wouldn't buck tradition unless I thought I could defensibly improve it.

Microdata is nice. It pushes toward the interleaving of representation for machines and for humans, which I like, but... it's a hassle. When I'm writing HTML, I want to specify as few attributes and elements as possible. If I could condense it into one element which takes a JSON data-uri, I'd be happier.

Not only is an embedded JSON data-uri faster to code, it requires less markup data and less DOM traversal. Representational State Transfer is all about the content-types, and HTML is all about the embedding. It even has an element for it: <object>. That seems like a better direction.

The final argument I can entertain for Microdata is that it does bind the machine-readable data to visual elements. I'm unsure that Grimwire can take advantage of compositional tools so fine-grained that individual DOM elements need semantic binding-- but this could change if the binding is used to do realtime content updates, or if VRUIs can make use of the granularity in some way not currently possible (semantic visual structures, for example).

And here's another point -- Microdata includes the itemtype attribute, which I think is important for discovery/routing. If I go with <object>, I'll likely have to use a non-standard attribute like itemtype, which I prefer not to do.

Two good answers. I hate that.


No comments:

Post a Comment