Data Urls Are Fun!

written by trotter on December 12th, 2008 @ 08:03 AM

Lately I’ve been playing with data urls in an effort to use them as an alternative way to build iPhone apps. W. Clawpaws wrote an interesting post on this a year ago, but it seems that not much has been done since. If it’s possible, I plan to have a simple library built by end of year that will allow you to write data url apps that connect to a central server when available. Basically, it’ll make the persistence and speed arguments for writing native apps null and void.

Anyway, enough of what I plan to do and more about actual data urls. “Data urls”http://en.wikipedia.org/wiki/Data_URI_scheme allow you to store a single image, some javascript, or even an entire web page in a url. The browser will then render that information as if it were pulling it from a normal http:// url. So they will increase the initial payload of your web page, but result in faster interactions once the page is loaded.

Data urls have a format of

data:[<MIME-type>][;charset="<encoding>"][;base64],<data>

So if you see something like data:text/html;base64,PGh0bWw+, you’re looking at a data url. To see one in action, click the link below and have a look at the url in your navigation bar.

Data url in action!

Check back in the near future for progress on the iPhone idea. In the meantime, enjoy playing with data urls.

Comments

  • Colin on 12 Dec 08:21

    That's badass. But I don't get why this is better for iPhone sites?
  • Trotter Cashion on 12 Dec 08:29

    It's interesting because you can go to the data url and then save it as a bookmark. Then it looks and feels like an app on your iPhone and will load immediately (without requiring the net) when you touch it. That's all good if you have a simple javascript app like a tip calculator, but if not good if you need to store and load new data. I'm working on a library that will help with the later.

Comments are closed

Options:

Size

Colors