Search code examples
javascripthtmljsongmailobfuscation

Why gmail source code does not show any html?


In chrome browser if you try to look in to the page source (ctrl+u say source code of inbox page) of Gmail it does not show you the HTML code, instead there is lot of JavaScript code mostly JSON formatted or so. Though you can see html head and meta tags.

My question is:

  1. Are they trying to hide their code?
  2. Do they use some kind of JavaScript templating to improve the performance?
  3. Is it one of the best practices to send response in form of JavaScript objects for some kind of improvement?

Solution

  • are they trying to hide their code?

    To some degree. They use Closure Compiler to minimize and obfuscate their code.

    http://googlecode.blogspot.com/2009/11/introducing-closure-tools.html

    Millions of Google users worldwide use JavaScript-intensive applications such as Gmail, Google Docs, and Google Maps. Like developers everywhere, Googlers want great web apps to be easier to create, so we've built many tools to help us develop these (and many other) apps. We're happy to announce the open sourcing of these tools, and proud to make them available to the web development community.

    Closure Compiler

    Closure Compiler is a JavaScript optimizer that compiles web apps down into compact, high-performance JavaScript code.


    Do they use some kind of JavaScript templating to improve the performance?

    Yes. From that same link

    Closure Templates

    Closure Templates grew out of a desire for web templates that are precompiled to efficient JavaScript. Closure Templates have a simple syntax that is natural for programmers. Unlike traditional templating systems, you can think of Closure Templates as small components that you compose to form your user interface, instead of having to create one big template per page.


    Is it one of the best practices to send response in form of JavaScript objects for some kind of improvement?

    If you're trying to write a rich JavaScript client then your best bet is to decompose your application into JavaScript objects.