TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How Google uses HTML5 to reduce startup latency for mobile Gmail

50 pointsby adamhowellover 15 years ago

7 comments

IgorPartolaover 15 years ago
So first they take monolithic code and modularize it. Then they bundle it back into a single piece of code. Then they do this:<p><pre><code> &#60;script id="lazy"&#62; // Make sure you strip out (or replace) comment blocks in your JavaScript first. /* JavaScript of lazy module */ &#60;/script&#62; &#60;script&#62; function lazyLoad() { var lazyElement = document.getElementById('lazy'); var lazyElementBody = lazyElement.innerHTML; var jsCode = stripOutCommentBlock(lazyElementBody); eval(jsCode); } &#60;/script&#62; </code></pre> What if my JavaScript code looks like this:<p>var x = "hello /* world */";<p>I wouldn't do it this way. Instead just bundle all your code into a single file and optimize its caching. No HTML5 needed: use HTTP headers.
评论 #1002130 未加载
alain94040over 15 years ago
I used to be impressed by hacks such as these, but now they mostly make me sad: in 20 years of computer improvements, we still have to resort to ugly hacks like these?<p>The chip on an iPhone runs at what, 600 MHz, maybe 800 MHz? My Apple II ran at 1 MHz. I was counting bytes then. I hope I'll see a day where I don't count bytes anymore :-)
评论 #1002578 未加载
arsover 15 years ago
How is this HTML5 specific? Everything written there applies to older versions too.<p>And the title is wrong - they are not using HTML5 to do anything, it's about how to reduce latency by lazy loading modules in the background.
评论 #1002094 未加载
评论 #1003980 未加载
waleedkaover 15 years ago
What surprised me was that parsing javascript took much longer than downloading is, even on a mobile phone connection! Anyone knows why after all these years we still don't have a way to download pre-compiled javascript?
评论 #1002512 未加载
评论 #1002100 未加载
tlrobinsonover 15 years ago
Why even bother using a script tag if you're just going to eval the text later? Just make it a text file so you don't have to worry about stripping or escaping comments.
评论 #1002773 未加载
bpraterover 15 years ago
Wow, using commented out Javascript to speed up load times and then parsing and evaling at run-time. That's a pretty interesting hack.
fauigerzigerkover 15 years ago
If that's HTML 5 I remain unconvinced.