如果Google的首页很小,为什么源代码有数百行呢? [英] If Google's homepage is so minimal, why is the source hundreds of lines of code?

查看:67
本文介绍了如果Google的首页很小,为什么源代码有数百行呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码已精简,但重新格式化后有几百行代码.我想象过这样一个最小的页面也将具有最少的代码. Google这么做的源头那么长,这是什么意思?我可以看到很多是javascript,但是给人的印象是,内联这么多javascript是不好的做法.

The code is minified, but reformatted is a few hundred lines of code. I'd imagine such a minimal page to have minimal code as well. What is it that Google is doing that the source is this long? I can see a lot of it is javascript, but I was under the impression that inlining so much javascript was bad practice.

推荐答案

该代码中的至少一个块用于Instant Search的ajax回调.

At least one chunk of that code is used for the ajax callbacks for Instant Search.

此外,当您考虑内联Java脚本是否不好时,应该考虑替代方法.如果代码在单独的文件中,则它将是另一个http请求,这意味着页面将以更高的延迟加载.

Also, when you consider whether inlining Javascript is bad, you should think about the alternative. If the code was in a separate file, it would be another http request, which means that the page would load with higher latency.

这篇关于如果Google的首页很小,为什么源代码有数百行呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆