On Tue, Mar 31, 2015 at 9:03 AM Yoav Weiss <yo...@yoav.ws> wrote:
Primary eng email
We already have a lot of complexity around pre-* in Chrome and I want to make sure that it offers measurable benefits over <link rel="prefetch">.
Is there a service that plans to experiment with this?
Please make sure this is controlled by the "Prefetch resources to load pages more quickly" settings and related pref. bnc@ is a good point of contact for that.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/net-dev/CAAuiYA-WnRGO1Ps%3DkCqeyTpOWC8UgyyQqNBnTcQ5b7pePFAYXA%40mail.gmail.com.--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+u...@chromium.org.
To post to this group, send email to net...@chromium.org.
What's unclear from the specification is how this relates to HTTP/2's Server Push, what the trade-offs are, and when one is more desirable than the other.I highlight this, because it seems to introduce added complexity into both user agents and developers' toolkits, and understanding the appropriate and efficient use seems key to deriving any gains from it.Is there a simple summary of "Why not Push?" As it stands, it seems all of the justifications in http://w3c.github.io/preload/#developer-server-and-proxy-initiated-fetching and http://w3c.github.io/preload/#early-fetch-of-critical-resources are seemingly addressible with push
, and to be honest, I'm unconvinced that http://w3c.github.io/preload/#early-fetch-and-application-defined-execution is an inherently good or virtuous thing - for developers or for implementors.
I'm unconvinced that http://w3c.github.io/preload/#early-fetch-and-application-defined-execution is an inherently good or virtuous thing - for developers or for implementors.
+1 to everything Pat & Yoav mentioned. I'll just add that server push+preload are complementary...
Server push is a transport feature that allows us to shave off an RTT on delivery of a resource, but it doesn't provide any particular mechanism for declaring which resources are to be pushed - i.e. there is no browser API, no JS callbacks notifying you of a received push, etc. Preload, on the other hand, is a declarative API for defining which resources need to be fetched, with what priority, with appropriate JS callbacks, etc.
In short, push is a latency optimization and preload is the declarative mechanism by which we can infer which resources may be eligible for server push.
On Tue, Mar 31, 2015 at 10:11 AM, Ryan Sleevi <rsl...@chromium.org> wrote:I'm unconvinced that http://w3c.github.io/preload/#early-fetch-and-application-defined-execution is an inherently good or virtuous thing - for developers or for implementors.It's a sorely needed and missing primitive. The simplest example is the long outstanding developer request for "async CSS", which is easily implementable with preload in a performant manner (visible to preloader, fetched with correct priority, etc), and also allows developers to define custom behaviors that go well beyond 'async' - e.g. defer execution until some additional+app-specific conditions are met. Same applies for any other content type and, best of all, preload can be used to implement various load/execute strategies that span any mix of content-types.. It's a building block for custom+smart resource loading strategies.
I don't think my concerns should block implementation; that is, I think the spec could be better explained in some areas (and this thread shows there's good information to be had that isn't in it), it clearly needs some work in other areas that we're unlikely to get until more implementation experience (matching requests and the MUST keep available requirements), and overall can be quite helpful.
One last thought experiment before you go off - given that you've put a lot of thought into how this can be helpful, can you put some thought into what the anti-patterns might be or look like? I think the work on idiomatic promises is a great example of how working through how the syntax enables boneheaded things, and what you "should" do instead, can lead to better experience for all.
A couple of questions:1) What's the relationship between Service Worker and this new feature?
2) How does it fit into the rational web platform/extensible web narrative? In other words, what are the primitives that I would need in order build my own <link rel=preload> custom element?
:DG<
In its essence, preload is a declarative fetch.One capability preload has which is missing from current fetch is the ability to declare the resource's download priority. (the `as` attribute)I believe that's the only missing primitive to implement a custom <link rel=preload>.
Will there be a way for a website to test for the implementation of this feature? For example, imagine a site wanted to use <link rel=preload> to load a stylesheet, without blocking on it. On older browsers, it would have to fall back to some other strategy (eg, xhr or a blocking rel=stylesheet). How would sites know to do that?
On Mon, Apr 6, 2015 at 2:58 PM, Ryan Sleevi <rsl...@chromium.org> wrote:On Mon, Apr 6, 2015 at 2:52 PM, Yoav Weiss <yo...@yoav.ws> wrote:In its essence, preload is a declarative fetch.One capability preload has which is missing from current fetch is the ability to declare the resource's download priority. (the `as` attribute)I believe that's the only missing primitive to implement a custom <link rel=preload>.So if https://www.w3.org/Bugs/Public/show_bug.cgi?id=26533 was resolved, this could be implemented via Service Workers (effectively)?SW does not provide the same functionality. As Yoav mentioned, preload is declarative fetch(): it enables developers to declare which resources need to be fetched and with which settings; these declarations do not require JS execution (and can be delivered via markup or HTTP headers), which makes them preload-scanner and optimization-server/proxy friendly; they allow application to decouple download from processing; they enable UA to initiate early(er) fetch of critical resources that may be hidden or delayed otherwise... SW can, of course, observe and respond to these requests, but it cannot and does not control when+which resource fetches are initiated by parent document,
On Tue, Apr 7, 2015 at 9:04 AM, 'Ilya Grigorik' via blink-dev <blin...@chromium.org> wrote:On Mon, Apr 6, 2015 at 2:58 PM, Ryan Sleevi <rsl...@chromium.org> wrote:On Mon, Apr 6, 2015 at 2:52 PM, Yoav Weiss <yo...@yoav.ws> wrote:In its essence, preload is a declarative fetch.One capability preload has which is missing from current fetch is the ability to declare the resource's download priority. (the `as` attribute)I believe that's the only missing primitive to implement a custom <link rel=preload>.So if https://www.w3.org/Bugs/Public/show_bug.cgi?id=26533 was resolved, this could be implemented via Service Workers (effectively)?SW does not provide the same functionality. As Yoav mentioned, preload is declarative fetch(): it enables developers to declare which resources need to be fetched and with which settings; these declarations do not require JS execution (and can be delivered via markup or HTTP headers), which makes them preload-scanner and optimization-server/proxy friendly; they allow application to decouple download from processing; they enable UA to initiate early(er) fetch of critical resources that may be hidden or delayed otherwise... SW can, of course, observe and respond to these requests, but it cannot and does not control when+which resource fetches are initiated by parent document,Actually, a Service Worker can exercise some control of those things. For example, in response to any event it can start new fetches (simply by calling "fetch".)With Streams, I could implement a Service Worker that scans the content of a document is it's being loaded and calls fetch when it encounters <link rel="preload">. With Request context it could even communicate to the resource scheduler that this is a prefetch, although I'm not sure that is hooked up yet.
Some limitations are:- If there's no Service Worker installed, the Service Worker can't do anything. So this wouldn't work for first load.- Chrome/Blink has already integrated a bunch of stuff that can interpret a byte stream as HTML content and scan for stuff in it. Of course this is possible to replicate this in JavaScript, but it's an investment.
On Tue, Apr 7, 2015 at 7:00 AM, Dominic Cooney <domi...@chromium.org> wrote:On Tue, Apr 7, 2015 at 9:04 AM, 'Ilya Grigorik' via blink-dev <blin...@chromium.org> wrote:On Mon, Apr 6, 2015 at 2:58 PM, Ryan Sleevi <rsl...@chromium.org> wrote:On Mon, Apr 6, 2015 at 2:52 PM, Yoav Weiss <yo...@yoav.ws> wrote:In its essence, preload is a declarative fetch.One capability preload has which is missing from current fetch is the ability to declare the resource's download priority. (the `as` attribute)I believe that's the only missing primitive to implement a custom <link rel=preload>.So if https://www.w3.org/Bugs/Public/show_bug.cgi?id=26533 was resolved, this could be implemented via Service Workers (effectively)?SW does not provide the same functionality. As Yoav mentioned, preload is declarative fetch(): it enables developers to declare which resources need to be fetched and with which settings; these declarations do not require JS execution (and can be delivered via markup or HTTP headers), which makes them preload-scanner and optimization-server/proxy friendly; they allow application to decouple download from processing; they enable UA to initiate early(er) fetch of critical resources that may be hidden or delayed otherwise... SW can, of course, observe and respond to these requests, but it cannot and does not control when+which resource fetches are initiated by parent document,Actually, a Service Worker can exercise some control of those things. For example, in response to any event it can start new fetches (simply by calling "fetch".)With Streams, I could implement a Service Worker that scans the content of a document is it's being loaded and calls fetch when it encounters <link rel="preload">. With Request context it could even communicate to the resource scheduler that this is a prefetch, although I'm not sure that is hooked up yet.Yeah, in theory it could be implemented in SW, if we'd ask developers to re-implement HTML tokenization and parsing in JS. The same is true for other core features (e.g. PreloadScanner).I think we can all agree that this is mostly a thought experiment. (i.e. I don't think anyone here seriously expects Web developers to actually do this in production)
Some limitations are:- If there's no Service Worker installed, the Service Worker can't do anything. So this wouldn't work for first load.- Chrome/Blink has already integrated a bunch of stuff that can interpret a byte stream as HTML content and scan for stuff in it. Of course this is possible to replicate this in JavaScript, but it's an investment.Another limitation: probable performance impact since tokenization & parsing would happen twice.
... cost of scanning bytes in JavaScript in a background thread, or that difference in performance would be decisive? I haven't measured it but I expect V8 can scan bytes pretty fast...
On Tue, Apr 7, 2015 at 6:13 PM, Yoav Weiss <yo...@yoav.ws> wrote:On Tue, Apr 7, 2015 at 7:00 AM, Dominic Cooney <domi...@chromium.org> wrote:On Tue, Apr 7, 2015 at 9:04 AM, 'Ilya Grigorik' via blink-dev <blin...@chromium.org> wrote:On Mon, Apr 6, 2015 at 2:58 PM, Ryan Sleevi <rsl...@chromium.org> wrote:On Mon, Apr 6, 2015 at 2:52 PM, Yoav Weiss <yo...@yoav.ws> wrote:In its essence, preload is a declarative fetch.One capability preload has which is missing from current fetch is the ability to declare the resource's download priority. (the `as` attribute)I believe that's the only missing primitive to implement a custom <link rel=preload>.So if https://www.w3.org/Bugs/Public/show_bug.cgi?id=26533 was resolved, this could be implemented via Service Workers (effectively)?SW does not provide the same functionality. As Yoav mentioned, preload is declarative fetch(): it enables developers to declare which resources need to be fetched and with which settings; these declarations do not require JS execution (and can be delivered via markup or HTTP headers), which makes them preload-scanner and optimization-server/proxy friendly; they allow application to decouple download from processing; they enable UA to initiate early(er) fetch of critical resources that may be hidden or delayed otherwise... SW can, of course, observe and respond to these requests, but it cannot and does not control when+which resource fetches are initiated by parent document,Actually, a Service Worker can exercise some control of those things. For example, in response to any event it can start new fetches (simply by calling "fetch".)With Streams, I could implement a Service Worker that scans the content of a document is it's being loaded and calls fetch when it encounters <link rel="preload">. With Request context it could even communicate to the resource scheduler that this is a prefetch, although I'm not sure that is hooked up yet.Yeah, in theory it could be implemented in SW, if we'd ask developers to re-implement HTML tokenization and parsing in JS. The same is true for other core features (e.g. PreloadScanner).I think we can all agree that this is mostly a thought experiment. (i.e. I don't think anyone here seriously expects Web developers to actually do this in production)Let me preface this by saying: I'm not very familiar with <link rel="preload"> and I don't have an opinion either way about it. That said...This argument seems to put an upper bound on the value of <link rel="preload">, because some web developers seem pretty motivated to do things to improve performance. With things like Polymer and Service Worker, framework authors can make things pretty accessible to "ordinary" web developers. So in effect it seems like you're saying that the performance benefit of preload is roughly the cost of scanning bytes in JavaScript in a background thread, or that difference in performance would be decisive? I haven't measured it but I expect V8 can scan bytes pretty fast...
On Wed, Apr 8, 2015 at 6:02 AM, Dominic Cooney <domi...@chromium.org> wrote:On Tue, Apr 7, 2015 at 6:13 PM, Yoav Weiss <yo...@yoav.ws> wrote:On Tue, Apr 7, 2015 at 7:00 AM, Dominic Cooney <domi...@chromium.org> wrote:On Tue, Apr 7, 2015 at 9:04 AM, 'Ilya Grigorik' via blink-dev <blin...@chromium.org> wrote:On Mon, Apr 6, 2015 at 2:58 PM, Ryan Sleevi <rsl...@chromium.org> wrote:On Mon, Apr 6, 2015 at 2:52 PM, Yoav Weiss <yo...@yoav.ws> wrote:In its essence, preload is a declarative fetch.One capability preload has which is missing from current fetch is the ability to declare the resource's download priority. (the `as` attribute)I believe that's the only missing primitive to implement a custom <link rel=preload>.So if https://www.w3.org/Bugs/Public/show_bug.cgi?id=26533 was resolved, this could be implemented via Service Workers (effectively)?SW does not provide the same functionality. As Yoav mentioned, preload is declarative fetch(): it enables developers to declare which resources need to be fetched and with which settings; these declarations do not require JS execution (and can be delivered via markup or HTTP headers), which makes them preload-scanner and optimization-server/proxy friendly; they allow application to decouple download from processing; they enable UA to initiate early(er) fetch of critical resources that may be hidden or delayed otherwise... SW can, of course, observe and respond to these requests, but it cannot and does not control when+which resource fetches are initiated by parent document,Actually, a Service Worker can exercise some control of those things. For example, in response to any event it can start new fetches (simply by calling "fetch".)With Streams, I could implement a Service Worker that scans the content of a document is it's being loaded and calls fetch when it encounters <link rel="preload">. With Request context it could even communicate to the resource scheduler that this is a prefetch, although I'm not sure that is hooked up yet.Yeah, in theory it could be implemented in SW, if we'd ask developers to re-implement HTML tokenization and parsing in JS. The same is true for other core features (e.g. PreloadScanner).I think we can all agree that this is mostly a thought experiment. (i.e. I don't think anyone here seriously expects Web developers to actually do this in production)Let me preface this by saying: I'm not very familiar with <link rel="preload"> and I don't have an opinion either way about it. That said...This argument seems to put an upper bound on the value of <link rel="preload">, because some web developers seem pretty motivated to do things to improve performance. With things like Polymer and Service Worker, framework authors can make things pretty accessible to "ordinary" web developers. So in effect it seems like you're saying that the performance benefit of preload is roughly the cost of scanning bytes in JavaScript in a background thread, or that difference in performance would be decisive? I haven't measured it but I expect V8 can scan bytes pretty fast...Not even close to what I was saying.
1. Some of what was shared above about what Service Workers can or can't do could have been more accurate. They can express a subset of preload.