

Storing Javascript in comment tags and later eval'ing it - derwiki
http://www.stevesouders.com/blog/2009/12/07/downloading-javascript-as-strings/

======
DrJokepu
This is pure evil. I don't like it. Even if it works and it's fast and
conceived by the ultra-smart people at Google, it is evil. Definitely sets off
my "WTF" alarm. Storing code in comments and then later retrieving it for
execution, what could possibly go wrong?

For example, there are ISPs (T-Mobile UK, I'm looking at you) that strip off
any comments from HTML, as a compression measure. Now I don't think that's a
good idea but it is a very widespread practice at 3G/GPRS ISPs and definitely
breaks this "code in comments" thing, especially since this whole thing was
designed with mobile devices in the mind.

~~~
aristus
If comments are a problem you can use a display:none textarea or a dozen other
things. The important bit is that steve has found another way to decouple the
HTTP loading from the Javascript engine parsing/loading. That's a fairly
significant result.

If something goes wrong it's probably fixable / avoidable. This kind of
extreme tuning may not for everyone but a 100msec saved is a happier user.

~~~
dutchflyboy
I was just wondering, why can't you start an async xmlhttprequest at the
onload event? It won't start the parsing until you tell it to, it won't block
the loading of the UI and it's not as obscure as using eval on comments.

~~~
aristus
In very high latency situations new connections are too expensive. Say you
have 300msecs packet latency, which is common in mobile. That means in worst
case, that XHR will take at least one second just to the DNS lookup and
establish the TCP connection to start downloading the file.

It's not the volts, it's the amps that kill you. So to speak.

------
chime
Any idea why Chrome>String is such an outlier? I would have imagined quite the
opposite from Chrome actually.

~~~
gills
I thought Chrome kept [compiled] common js locally? I could be wrong. But it
would seem explain some of the difference.

~~~
dutchflyboy
Yes, probably. That's why this sort of performance tests should only be done
with an empty cache. Otherwise it isn't a fair comparison.

