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.
Avoid lines longer than 80 characters. When a statement will not fit on a single line, it may be necessary to break it.
To view only the source code, press Ctrl + U on your computer's keyboard. Right-click a blank part of the web page and select View source from the pop-up menu that appears.
At least one chunk of that code is used for the ajax
callbacks for Instant Search.
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.
The JavaScript is probably not inlined in their unbuilt source. That would be potential bad practice. By inlining it into the page source when built, the page won't have to make any additional HTTP requests to download a separate resource file, as HTTP requests are one of the slowest parts of loading a web page.
The sheer amount of JS is, by my guess, probably due to a lot of common libraries and code shared among many of their pages, and trying to have it not load on their homepage would end up involving a lot of unnecessary and nasty workarounds in their code. Plus, the UI may look simple, but how much is actually happening under the hood? There are Google accounts to worry about, instant and voice searching to do, analytics tracking, etc.
In the end, however, you probably won't truly know unless you get a Google engineer to divulge their secrets, or get a job with them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With