Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-15 Thread Jake Archibald
Thanks, updated my code examples to reflect this On 14 March 2014 23:57, Boris Zbarsky bzbar...@mit.edu wrote: On 3/14/14 6:04 PM, Jake Archibald wrote: Any guarantees of ordering if fully cached? I believe no. -Boris

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-15 Thread Jake Archibald
On 15 March 2014 00:31, Kyle Simpson get...@gmail.com wrote: I'd say the first syntax is a bit verbose for what I was dreaming 4 years ago when I started asking for a simple script preloading mechanism, but it's just this side of acceptable. If we have to take the second approach, I say

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-15 Thread Jake Archibald
On 15 March 2014 00:35, Kyle Simpson get...@gmail.com wrote: there's a seemingly implicit requirement that we have to get both ES6 promises and DOM promises to land for these suggested approaches to work. ES6 promises are already in Chrome stable, they're on the route to stable in Firefox.

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-15 Thread Kyle Simpson
As I noted above, what we need to know (and I guess we need to know this from all browsers) if there's a *guarantee* of a-b-c execution order (even if all 3 are executing async) I don't believe there is such a guarantee, unless the spec spells it out explicitly. The `async=false` stuff

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-15 Thread Kyle Simpson
I'd say the first syntax is a bit verbose for what I was dreaming 4 years ago when I started asking for a simple script preloading mechanism, but it's just this side of acceptable. If we have to take the second approach, I say that's unacceptably more verbose/complex and falls short of my

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-15 Thread Boris Zbarsky
On 3/15/14 11:36 AM, Kyle Simpson wrote: The `async=false` stuff in the spec talks about dynamically loaded (not parser loaded) scripts going into a queue so they are downloaded in parallel, but executed in request-order from the queue. Then those are guaranteed to be serialized. The

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-14 Thread Jake Archibald
This, along with Ilya's proposed link rel=preload ( https://docs.google.com/a/google.com/document/d/1HeTVglnZHD_mGSaID1gUZPqLAa1lXWObV-Zkx6q_HF4/edit#heading=h.x6lyw2ttub69), and JavaScript modules ( https://github.com/dherman/web-modules/blob/master/module-tag/explainer.md) gives us everything we

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-14 Thread Kyle Simpson
This, along with Ilya's proposed link rel=preload ( https://docs.google.com/a/google.com/document/d/1HeTVglnZHD_mGSaID1gUZPqLAa1lXWObV-Zkx6q_HF4/edit#heading=h.x6lyw2ttub69), and JavaScript modules ( https://github.com/dherman/web-modules/blob/master/module-tag/explainer.md) gives us

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-14 Thread Jake Archibald
On 14 March 2014 20:10, Kyle Simpson get...@gmail.com wrote: Is link rel=preload going to fire this loaded event after it finishes pre-loading but BEFORE it executes (or, rather, BEFORE because it doesn't execute them at all)? link rel=preload doesn't execute (you can use it to preload

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-14 Thread Boris Zbarsky
On 3/14/14 5:03 PM, Jake Archibald wrote: Do you know what browsers do with a fully cached script? script src=url is always executed async when inserted into the DOM, cached or not. scripttext/script is executed sync. -Boris

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-14 Thread Jake Archibald
On 14 March 2014 21:05, Boris Zbarsky bzbar...@mit.edu wrote: On 3/14/14 5:03 PM, Jake Archibald wrote: Do you know what browsers do with a fully cached script? script src=url is always executed async when inserted into the DOM, cached or not. Any guarantees of ordering if fully cached?

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-14 Thread Boris Zbarsky
On 3/14/14 6:04 PM, Jake Archibald wrote: Any guarantees of ordering if fully cached? I believe no. -Boris

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-14 Thread Kyle Simpson
So, if that's how we think this would work, we need to understand how the `execScript(..)` logic is going to be treated. Is creating a script element dynamically and inserting it going to make sure that it either: a. executes sync b. executes async, but a.js will *definitely* execute

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-14 Thread Kyle Simpson
I'd also like to make the observation that putting link rel=preload.loaded() together with script.loaded(), and indeed needing a promise mechanism to wire it altogether, is a fair bit more complicated than the initial proposals for script preloading use-cases from the earlier threads over the

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-14 Thread Domenic Denicola
There is no such thing as DOM promises. From: Kyle Simpsonmailto:get...@gmail.com Sent: ‎3/‎14/‎2014 20:35 To: whatwg@lists.whatwg.orgmailto:whatwg@lists.whatwg.org Subject: Re: [whatwg] Promise-vending loaded() ready() methods on various elements I'd also like

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-14 Thread Boris Zbarsky
On 3/14/14 8:31 PM, Kyle Simpson wrote: As I noted above, what we need to know (and I guess we need to know this from all browsers) if there's a *guarantee* of a-b-c execution order (even if all 3 are executing async) I don't believe there is such a guarantee, unless the spec spells it out

[whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-12 Thread Jake Archibald
One of the problems with async scripting is doing something when/if it's ready. A complete solution looks like this https://gist.github.com/jakearchibald/7662e012462c7537a075, it would be a lot easier if we could just do: thing.loaded().then(function() { console.log('loaded'); }, function() {

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-12 Thread Boris Zbarsky
On 3/12/14 7:23 AM, Jake Archibald wrote: == img/link/script/document/iframe .loaded() == If the element hasn't loaded or is loading, vend a promise that resolves/rejects on its load/error event. If the element has fired load/error and isn't loading due to a source change, vend a

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-12 Thread Jake Archibald
On 12 March 2014 13:15, Boris Zbarsky bzbar...@mit.edu wrote: On 3/12/14 7:23 AM, Jake Archibald wrote: == img/link/script/document/iframe .loaded() == If the element hasn't loaded or is loading, vend a promise that resolves/rejects on its load/error event. If the element has fired

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-12 Thread Boris Zbarsky
On 3/12/14 9:32 AM, Jake Archibald wrote: You're right, I was short on detail for that case. img.src = foo; var promise1 = img.loaded(); img.src = bar; I expect promise1 to reject with an AbortError. No, the case I'm worried about is when the first load has already finished, you call

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-12 Thread Domenic Denicola
From: whatwg-boun...@lists.whatwg.org [mailto:whatwg-boun...@lists.whatwg.org] On Behalf Of Boris Zbarsky // img is already loaded sometimes // Would like to observe a new load var promise1 = img.loaded(); // oops! This will be pre-resolved if // we were

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-12 Thread Boris Zbarsky
On 3/12/14 10:17 AM, Domenic Denicola wrote: With promises you should only ask for the loaded promise *after* setting `src` Ah, fair. I'd been hoping we could get away without having to very carefully order the code, but I'm just not seeing a way to do that. Except, I suppose, for the

Re: [whatwg] Promise-vending loaded() ready() methods on various elements

2014-03-12 Thread Jake Archibald
On 12 March 2014 14:17, Domenic Denicola dome...@domenicdenicola.comwrote: var img = document.createElement(img); var promise1 = img.loaded(); img.src = foo.png; var promise2 = img.loaded(); // (1) will promise1 be immediately fulfilled, since img has about:blank or similar loaded already?