Guy
Guy

Reputation: 14790

How does gmail work under the hood

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??

Upvotes: 6

Views: 6208

Answers (1)

Matthew Lock
Matthew Lock

Reputation: 13476

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_interface

Upvotes: 5

Related Questions