Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move hero image preload out of experimental #814

Merged
merged 4 commits into from
Jun 3, 2020
Merged

Conversation

sebastianbenz
Copy link
Collaborator

@sebastianbenz sebastianbenz commented May 29, 2020

This also changes the transformer to only run if there a no pre-existing image preloads.

Copy link
Collaborator

@patrickkettner patrickkettner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}
}
return false;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuing my series of "unhelpful comments that make the code less readable"...

return [...head.children].any(this.isImagePreload)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the destructuring? I think head.children.some(this.isImagePreload); does the trick as well (and is easy to read).

@@ -6,6 +6,7 @@
<link rel="preload" href="https://cdn.ampproject.org/v0.js" as="script">
<script data-auto async src="https://cdn.ampproject.org/v0.js"></script>
<script async src="https://cdn.ampproject.org/v0/amp-video-0.1.js" custom-element="amp-video"></script>
<link rel="preload" href="https://amp.dev/static/samples/img/tokyo.jpg" as="image" data-hero>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for my own edification - what is the purpose of the data attr?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For being able to track which images have been identified as hero images

@sebastianbenz sebastianbenz merged commit 4b59cdc into master Jun 3, 2020
@sebastianbenz sebastianbenz deleted the hero-experimental branch June 3, 2020 16:51
@westonruter
Copy link
Member

For images that have srcset and sizes, this may not work as expected: #823.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants