The HTML structure of webmail interfaces: Gmail, Hotmail, and Yahoo Mail

As part of the Zentact project I’ve been working on, we were asked to integrate with various webmail clients. This makes it easy to manage your contacts while sending email.

Doing this was a bit of a pain. Since all code is minified, and they all use Javascript events differently, there was a good bit of working to figure out the details. I wanted to share this info in a blog post for programmers who come along in the future. If you don’t know/care about HTML, Javascript events, the DOM, YUI, or AJAX, this post is not for you. Please enjoy one of my other fine posts, perhaps this post on military code names.

Before I begin: there was a ton of info learned (and already forgotten) about this process. This is not a complete guide, but is mostly a brain dump from implementing UI integration on three different webmail interfaces.

  • Gmail uses 6-character strings, [A-Za-z0-9] for all its classes. These classes remain the same from load-to-load, but I believe that they may change over time with minification. IDs are not as constant, and many are dynamically assigned. These start with a colon.
  • When you’re working with events, you may get inconsistent results. Some events are not fully propagated, they get captured and you can’t find out about them. If onclick doesn’t work, try listening for onmousedown or onmouseup. One of them may get you notified of the event you want. Same advice goes for onkeydown, onkeyup, and onkeypress. That being said, once you get into these, be sure to realize that these three events will occur in particular orders. Make sure you’ll be getting notified at the right time.
  • All of the webmail UIs use iframes. This lets them keep their code for loading the UI separate from the code to display the UI. I know there’s some cross-site scripting implications in this, but I’m not sure of all the details. Gmail’s loading screen (the loading bar they show you) is a different iframe than the one that shows you the inbox. All of these iframes are at the root of the document, and there’s nothing else in there.
  • You could use Firebug break points to pause the code and examine what’s going on, but nearly all JS is minified. Since breakpoints can only be set by line, and there’s multiple functions defined per line, it ends up not being helpful.
  • For its UI, Yahoo seems to use YUI, plus some other stuff on top of that. There’s some weird results because of this. The body of the email editor is a group of DIVs, some are invisible, some are for border decoration, and others are for the background of the editor.
  • When we inserted elements into Yahoo Mail using regular DOM operations, they would appear behind other page elements, until another part of the UI was interacted with, when the screen would redraw and then they would bump into place. YUI seems to have its own redraw/repaint functionality, and it won’t play nice with DOM manipulations.
  • Hotmail is strangely one of the less-exotic interfaces. They use consistent IDs. I don’t think they’re hand-coded, however, because they submit to a naming scheme that seems too machine-generated. But still, they are there, and you should take advantage of them.
  • When you’re using events, and you get notified of an event, use the event.originalTarget property to find out where in the DOM you are. That’s useful information when you’re dealing with a DOM tree of nonsense class names and IDs.
  • When you’re trying to figure out where in a DOM tree you are, don’t hesitate to go up several levels and check a great grandparent node, or a “cousin” node. Once you get a single point of reference, you can generally work out where everything else is, relative to it.
  • Some UIs open each message in its own iframe, which means that IDs are consistent since they’re in their own namespace.

Also, thanks to Nate Koechley for helping me get through some of the Yahoo details.

If you’ve got other questions, shoot me an email. I remember more stuff, but might need a good question to shake it loose.

Code reviews

I’ve been quoted in a series of articles at CIO.com on code reviews. The two particular ones I’m in are

Neat!

The author of the articles is Esther Schindler, who has also written articles like “Four Non-Obvious Things Pink Floyd Can Teach Your Team“. I <3 analogies.

acts_as_presenter

Hey kids! Guess who’s presenting at Acts as Conference, 2009! These guys! Also, some guy with a big nose.

I’m giving a talk on OAuth, the greatest way to protect your APIs while keeping your users secure. Simple, easy, fun, and it might even get you laid. The amazing, spectacular, splendiforous OAuth! Yea. It’s gonna be that good.

And now, for the official marketing:

Acts as Conference 2009 is a two-day Rails conference that will make you a more competitive Rails developer by learning from those driving the innovation that is fueling the Rails community. Held February 6th and 7th in Orlando, Florida, Acts as Conference features a great speaker lineup, free food, a chance to meet with Rails innovators, and a live via video Q&A session with David Heinemeier Hansson. At $125 dollars and limited to 175 attendees, the conference will sell out fast, perhaps faster than last year. Register today at http://www.actsasconference.com. See you there!

Thanks Adam Savage

I saw this video of Adam Savage talking at The Last Hope this past year. I recommend it. It’s awesome to see how dedicated he is, and what it takes to produce such great stuff.

Other than getting a preview of (then) new Mythbuster footage and getting  to see a downloaded AVI of The Dark Knight on Adam’s hard drive, I really liked when he showed his projects folder. It was cool seeing that he works on things when he feels like it, and then saves his progress so he can come back later.

I’ve been trying to get more organized lately (what with the Getting Things Done/Agile planning at Cloudspace and all), so it’s something that stuck out for me, that I wanted to share with you.

Capitalist Showers, Economics Showers, and using less water.

I saw my friend Kitzzy’s tweet about navy showers a while ago, and I’ve been trying them out. No, “navy shower” isn’t what you might think.

Basically, it’s a braindead-simple way to reduce water and electricity/gas usage, with no inconvenience to you. Plus, I always seem to take quicker showers, which means I can clear out another blog or two from my RSS feeds.

Before I go off from this, I wanted to share a trick, if you’re interested in trying this out.

Pro tip: I recommend not shutting off the water completely. I find it is useful to wash soap off of your hand when you want to go turn the handle — very slippery otherwise. The Navy probably has foot-activated water valves.

Anyways, this navy shower concept got me thinking about minimizing consumption and efficiently using resources. It’s an economics issue — how do I get the most use/value out of a fixed amount of resources? From here, I started thinking about business.

It should be no surprise that businesses want to minimize use of resources. The less they have to spend on getting raw materials, the more those resources can be applied to other things, like salaries, and stock dividends. It’s even more aggressive in small businesses with slim margins, where becoming more efficient can mean the ability to hire more employees and grow, or purchase better equipment.

And this is where capitalism and the eco-movement intersect. Going with the “saving water” idea; let’s say you’re a business that makes Gadgets, and it takes 1000 gallons of water to make a Gadget. If you figure out how to make a Gadget with 600 gallons of water, you’ve already got a savings on your hands. One of your costs has been cut by 40%. Hooray! Fire up the yacht!

This is how businesses have worked for a very long time. “Efficient use of resources” should be a mantra in every group. But now with the eco-movement, companies are doubly-motivated to use resources more efficiently. Because now, when they become more efficient, they can advertise their “greenness” and get a PR boost on top of their new found financial savings. Some of them even charge more for their new “green” product, giving them a bigger return on the investment.

So that’s it. Your daily dose of economics and business. Of course, if you still want to do more to reduce your use of resources, try navy showering with a friend.

Zentact reaches out to web and says hi. Web waves back.

It’s official, Zentact is live. This is the product that Cloudspace has been building for the past several months for John Sampson, Eric Marcoullier, and Jared Brandt (who also makes some damn fine wine).

The skinny of Zentact is that it’s an address book with a Firefox extension that lets you know when someone in your address book might be interested in the page you’re viewing. Go to the site and give it a whirl.

It has been an exciting day. Watching the comments roll in on Twitter is awesome, and so is watching the emails go out from Zentact.

Mashable loves us. So do the fine folks at ReadWriteWeb and VentureBeat. And finally, an excellent review of Zentact from Mr Howard Lindzon. Also, coverage from some unbiased sources, like Cloudspace. 😀

You should check it out. You’ll need a invite code, and you can use TIMZEN. Or, just sign up with this link, which magically includes the Zentact invite code. Let me know what you think.