
Resource Hints for Modern Browsers - buro9
https://w3c.github.io/resource-hints/
======
buro9
If you're using Firefox or a Chrome Beta, then you can view the
`rel=preconnect` resource hint in use on my site
[https://www.lfgss.com/](https://www.lfgss.com/)

You'll see it as a HTTP header:

    
    
        link:<//cdnjs.cloudflare.com>; rel=preconnect, <//www.google-analytics.com>; rel=preconnect, <https://login.persona.org>; rel=preconnect, <https://static.login.persona.org>; rel=preconnect, <//fonts.googleapis.com>; rel=preconnect, <https://fonts.gstatic.com>; rel=preconnect; crossorigin
    

It made a significant difference to Google Fonts speed as well as Persona.

I'd definitely recommend using resource hints in your base HTML template or
server controller, for the assets that you know every page will access. This
is the low hanging fruit... making this super specific for each page likely
won't fit into your CMS easily.

~~~
SimeVidas
But what if the browser already has all the page’s subresources in the network
cache? Wouldn’t the preconnects then be a waste?

~~~
buro9
The browser can make sense of this, the browser can also make sense of not
doing a DNS prefetch if it already has one in-flight for the preconnect, etc.

The gains are such that it is better to add the hints than not.

------
pdkl95
> Additionally, the user agent MAY provide user setting to control the use of
> resource hints.

Why isn't this MUST? Users absolutely have to have a choice, because
prefetching (even just DNS) allows tracking ("analytics") information to leak.

------
richbradshaw
What's the best way to see that the browser does anything with this - does
Chrome have visibility of this in the dev tool somewhere?

------
amelius
I'm wondering why W3C is using some limited declarative "language" instead of
the more powerful Javascript to figure out these hints.

~~~
wtbob
Wow, Poe's Law strikes again. Are you making a joke or are you serious?

~~~
amelius
I wanted to make clear that I was serious, but there is no seriousness
punctuation, only irony punctuation [1]

[1]
[https://en.wikipedia.org/wiki/Irony_punctuation](https://en.wikipedia.org/wiki/Irony_punctuation)

~~~
wtbob
Well, then see drdaeman's response. There's no reason to add _anything_ more
which requires JavaScript unless there's absolutely no alternative.

Otherwise, why not just serve up a blank page which executes JavaScript to add
characters one at a time?

------
malft
How does preconnect crossorigin=anonymous differ from a regular preconnect?
(I'm guessing some http2 thing?)

------
eyelash
The 'prefetch' relation exploit vector, coming soon to a browser near you.

