tags:

views:

793

answers:

1

Just out of curiosity, I'm wondering how gmail does what it does. After looking in the source of the page you don't see any links, onclick methods and javascript. I understand they hide the javascript, but still the page knows that there was a click. Is there a daemon thread running that listens for your clicks? How does it work??

+2  A: 

A bit old now but here's an article kind of explaining Gmail under the hood: http://johnvey.com/features/gmailapi/ (see section "About the Gmail engine and protocol")

The item most relevant to this project is what I refer to as the “DataPack”, a base HTML file that contains only JavaScript array declarations that the UI engine parses and then uses to determine what to update. The advantages of this should be immediately obvious: reduced traffic load, and increased functionality — especially for developers who no longer have to resort to crude “screen scraping” techniques to interface with web applications. Although the ideal situation for external developers would be an XML-based DataPack, the JavaScript version is sufficient (and I suspect it was chosen for performance reasons as well).

The DataPack format consists of individual “DataItems”, or JavaScript arrays wrapped in a envelope function. An example:

D(["ts",0,50,106,0,"Inbox","fd36721220",154]);

Wikipedia's entry is pretty good at a brief overview too: http://en.wikipedia.org/wiki/Gmail%5Finterface

Matthew Lock
the first link is dead...didn't think about wikipedia.. but it's a bit shallow..
Guy
And here we have the problem of linkrot and relying on an external site for the bulk of an answer.
random
actually the regular link does work, just updated it
Matthew Lock
The DataPack format is replaced by some super-array a few years ago. Just have a look at the source of a Gmail page and look for "VIEW_DATA"
Marcel Korpel
I've made this post into a Community Wiki so it can be edited as the info is already out of date!
Matthew Lock