ampproject / ampproject/amppackager

Preconnect/dns-prefetch resource hint against web.dev best practices

Open
#489 2 comments 0 reactions 0 assignees View on GitHub
fixit
Dominant language
Go
Stars
141
Forks
46
PR merge metrics
No merged PRs in 30d

Description

I think this combined preconnect and dns-prefetch resource hint is not always doing what it is supposed to do depending on the browser:

https://github.com/ampproject/amppackager/blob/f1d819c86e9ab7f1f1a6578b7b4017e60fa02dc8/transformer/transformers/linktag.go#L69

As far as I can tell, the `dns-prefetch` is meant to be the fallback in case the `preconnect` is not supported (as the `preconnect` would include a DNS resolution). However, the `dns-prefetch` is mentioned first, which seems odd.

Also, according to web.dev, best practice is to use two separate hints with the `dns-prefetch` as the second hint serving as a fallback, as using a combined hint will break in Safari:
https://web.dev/preconnect-and-dns-prefetch/#resolve-domain-name-early-with-reldns-prefetch

Contributor guide

Open the contributing guide

Research direction

Start in transformer/transformers/linktag.go around line 69 and compare the generated resource hint with the web.dev guidance linked in the issue. Check how the transformer represents preconnect and dns-prefetch hints, then verify that the output follows the browser-compatible fallback behavior described there.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
performance, web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.