linkcheck
linkcheck copied to clipboard
Handle preconnect links correctly
<link rel="preconnect" href="https://www.googletagmanager.com" />
is a hint to start DNS lookup and so on, for the domain. The actual page can be 404.
Current status:
- Preconnect links are considered like any other link, being fetched / HEAD-ed when
-e
. - For the specific example of
<link rel="preconnect" href="https://www.googletagmanager.com" />
, this means a HTTP 400 error is reported (because https://www.googletagmanager.com is not a valid page).
Ideal solution:
- Preconnect is recognized and
linkcheck
then merely verifies that the domain exists and connects. -
linkcheck
might show a warning when there's apreconnect
link and then no actual link to that domain. (Problem: many times the actual link is constructed in JavaScript.)
Realistic solution:
- Preconnect links are ignored. After all, it is just a hint, and sooner a later an actual link is coming.
Same is true for <link rel="dns-prefetch" ...>
. I also propose to just ignore those.
dns-prefetch
and preconnect
seem to be the only ones one should ignore (source).
So the selector should not be link[href]
but link[href]:not([rel~='preconnect']):not([rel~='dns-prefetch'])
.
@filiph Any updates on this? Is there a workaround with the latest version to just ignore preconnect links?
Sorry for the late reply. There is no workaround with the latest version but if you build linkcheck with the development version of Dart, you should get the behavior you expect. Sorry for not being more helpful — can't really sink more time into this at the moment.