ampproject / ampproject/amp-toolbox

Resource hints are misprioritised in the ReorderHead transformer

Open
#606 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
459
Forks
242
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)`.

Related issue in the Go implementation: https://github.com/ampproject/amppackager/issues/391

Contributor guide

Open the contributing guide

Research direction

Start at the ReorderHead transformer and its documented head ordering, then read the linked ampproject/amppackager#391 issue and the referenced AMP performance guidance. Decide whether resource hints should move after entry (0) or be split by purpose, and verify the resulting ordering; the payload names no test file.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.