javascript - 为什么 gmail 源代码不显示任何 html?

标签 javascript html json gmail obfuscation

在 chrome 浏览器中,如果您尝试查看 Gmail 的页面源代码(ctrl+u 表示收件箱页面的源代码),它不会向您显示 HTML 代码,而是有很多JavaScript 代码主要是 JSON 格式左右。虽然你可以看到 html head 和 meta 标签。

我的问题是:

  1. 他们是否试图隐藏他们的代码?
  2. 他们是否使用某种 JavaScript 模板来提高性能?
  3. 为了某种改进,以 JavaScript 对象的形式发送响应是否是最佳实践之一?

最佳答案

are they trying to hide their code?

在某种程度上。他们使用 Closure Compiler 来最小化和混淆他们的代码。

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?

是的。来自同一个链接

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?

如果您正在尝试编写丰富的 JavaScript 客户端,那么最好的办法是将您的应用程序分解为 JavaScript 对象。

关于javascript - 为什么 gmail 源代码不显示任何 html?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15964253/

相关文章:

javascript - JavaScript 中 FOR 循环的复杂条件

javascript - 根据元素是否折叠更改 Bootstrap 折叠按钮中的文本

html - 定位一个高度有限的固定元素(最大高度)

php - 来自 steamcommunity JSON 上的 PHP file_get_contents 的 JQuery $.getJSON

javascript - Chart.JS 多线图表,来自 JSON 的行数未知

javascript - 检查一个数组是否包含在另一个数组中

javascript - 如何从客户端 Controller 中找到 aura 组件中的元素?

javascript - 如何立即触发一个函数?

html - 如何使用 CSS 在标题 block 中垂直居中包含水平居中文本的图像?

php - FOSRestBundle,过滤 JSON 响应中的对象属性