[whatwg] Deferring javascript download and execution until after onload

Kyle Simpson getify at gmail.com
Wed Nov 28 21:05:11 PST 2012


Ian,

> The cost of parsing the script can be done async, even off the main thread 
> in theory, so it's a non-issue.

You have asserted many times that parsing is off the main thread, therefore it doesn't matter. That makes the giant (and I think faulty) assumption that the device in question has enough spare resources to give multiple threads, which not all do, and that all threads can run in parallel without hurting each other and/or the overall performance.

There have been a number of articles referencing issues where complex scripts do in fact take a non-trivial amount of parsing time on limited mobile devices. Even if such work wasn't strictly blocking the main UI thread, the fact that it may take a lot of processing (or memory) power from the device might very well mean that large parsing tasks could starve necessary resources, so even if it's on another thread, there's still very much not a "non-issue" to consider.

I tried quick google searching just now to dig some specific articles up and failed to find what I remembered reading, but perhaps others on the list know what I'm talking about. I recall someone showing that jquery.js took over 1+ second to parse on a mobile device, but I can't remember the exact numbers. I remember being shocked at how crazy long jquery.js took to parse.

Here's something though that seems it's related: https://github.com/tolmasky/language/issues/18

------------

Moreover, as has been mentioned many times in various threads (and you seem to gloss over repeatedly), the gmail mobile team passed down large amounts of javascript "hidden" in a javascript /* … */ comment, so as to prevent that large amount of code from being parsed, until "later" when the hit was acceptable, because they felt that the parsing and/or execution was non-trivial enough to unacceptably slow down their app's startup time.

IIRC, this was their post: http://googlecode.blogspot.com/2009/09/gmail-for-mobile-html5-series-reducing.html

In any case, your assumption that parsing is a non-issue seems to fly in the face of not only some explicit evidence to the contrary, but there have also been some comments in various threads from browser vendor devs that lent credence to the fact that parsing could in fact be somewhat costly.

Do you have explicit evidence to the contrary that no such possible performance issues during parsing could possibly exist on any device or with any script in the wild? It would be nice if you could show such contrary evidence instead of dismissing or ignoring the arguments and evidence already out on the table.

The coming "module" feature (in ES6 or whatever) could make this worse, because AIUI, the parsing/compilation stage is where the browser will resolve static dependencies, so it's THAT stage which very well might be taking a lot longer while it fetches dependency resources.


--Kyle








More information about the whatwg mailing list