ampproject / ampproject/amppackager
Resource hints are misprioritised in the reorderhead transformer
- Dominant language
- Go
- Stars
- 141
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Description
The `reorderhead` transformer puts the resource hints at the back of the head (see entry `(8)`):
```
// ReorderHead reorders the children of . Specifically, it
// orders the like so:
// (0) tag
// (1) (inserted by ampruntimecss.go)
// (2) remaining <meta> tags (those other than <meta charset>)
// (3) AMP runtime .js <script> tag
// (4) AMP viewer runtime .js <script> tag
// (5) <script> tags that are render delaying
// (6) <script> tags for remaining extensions
// (7) <link> tag for favicons
// (8) <link> tag for resource hints
// (9) <link rel=stylesheet> tags before <style amp-custom>
// (10) <style amp-custom>
// (11) any other tags allowed in <head>
// (12) AMP boilerplate (first style amp-boilerplate, then noscript)
```
This means that resource hints that are provided to meet the [performance guidelines in the Amp documentation](https://amp.dev/documentation/guides-and-tutorials/optimize-and-measure/optimize_amp/#optimize-the-amp-runtime-loading) will reordered to only appear after the actual download triggers they are meant to optimize.
I think that either the entry `(8)` should be brought up to appear after `(0)` in general, or resource hints should be split into two groups where the Amp-related ones are brought higher while the rest stay in `(8)`.
cc @sebastianbenz
Contributor guide
Research direction
Start at the `reorderhead` transformer and its ordering comment, especially entry `(8)` for resource hints. Determine how the current ordering conflicts with the AMP performance guidance, then establish whether resource hints should move after `(0)` or be split into AMP-related and other groups; done means the transformer reflects the chosen ordering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100