>
On an iPhone 2.2 device, 200k of JavaScript held within a block comment adds 240ms during page load, whereas 200k of JavaScript that is parsed during page load added 2600 ms. That's more than a 10x reduction in startup latency by eliminating 200k of unneeded JavaScript during page load! Take a look at the code sample below to see how this is done.
But once again this is an issue of when to eval the code, not when to load it. Put the script tag at the end of the page, so that it gets eval'ed after most of the page is already built.
I guess that's true. Still, XHR respects HTTP headers. You could request the code and immediately get it out of the browser cache if it is there. I see the problem they are trying to solve, but the solution is so obtuse I can't bring myself to using something like this.
> On an iPhone 2.2 device, 200k of JavaScript held within a block comment adds 240ms during page load, whereas 200k of JavaScript that is parsed during page load added 2600 ms. That's more than a 10x reduction in startup latency by eliminating 200k of unneeded JavaScript during page load! Take a look at the code sample below to see how this is done.
But once again this is an issue of when to eval the code, not when to load it. Put the script tag at the end of the page, so that it gets eval'ed after most of the page is already built.