igrigorik / resource-hints

Moved to...
https://github.com/w3c/resource-hints
32 stars 7 forks source link

Document behavior on mixed prioritization for same asset (preload+prefetch, etc) #1

Closed igrigorik closed 10 years ago

igrigorik commented 10 years ago
willchan commented 10 years ago

I'm still not sure if the rule should be "select the lower priority". For example, let's say I know I'm using jQuery on this page. I preload it. And then a server-side rendering plugin knows it's using jQuery for the next page in the e-commerce purchase sequence, so it adds a prefetch for jQuery. Why should this result in a lower priority?

igrigorik commented 10 years ago

@willchan to generalize... I have multiple systems inferring priorities and feeding hints to the browser (e.g. developer specified hints, server emitted hints, browser heuristics, etc), how should the browser determine the right priority when multiple hints for the same resource are emitted?

For example, system A knows that thing.js is required on the next page, so it adds a prefetch hint, whereas system B knows that thing.js is also needed on the current page, so it emits a preload hint.

The right decision is to assign a lower priority whenever there is a conflict (where lower means more important) because by taking this route you guarantee that you won't hurt performance: at least one system has declared that the resource is important, hence its a low priority resource. The fact that the same resource is also needed by other components (at higher priority) is beside the point.

willchan commented 10 years ago

Oh, I think we had a terminology conflict. I think of higher priority as being more important. I have to confess, I think my interpretation is more common :) It's true that a lower integer priority is often how it gets implemented though.

igrigorik commented 10 years ago

</facepalm> ... then we're saying the same thing! In fact, I use "low priority" throughout the spec in the way you interpreted it. Updated the language in the ticket.

willchan commented 10 years ago

OK, great :) I agree!

igrigorik commented 10 years ago

@willchan does that look reasonable?

willchan commented 10 years ago

Lgtm On Jul 25, 2014 9:34 AM, "Ilya Grigorik" notifications@github.com wrote:

@willchan https://github.com/willchan does that look reasonable?

— Reply to this email directly or view it on GitHub https://github.com/igrigorik/resource-hints/issues/1#issuecomment-50173292 .