-
Notifications
You must be signed in to change notification settings - Fork 385
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
Add PreloadHeroImage Optimizer transformer #5350
Conversation
list($scheme, $host, $port, $user, $pass, $path, $query, $fragment) = array_values( | ||
array_merge( | ||
self::URL_DEFAULT_PARTS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels a bit risky as it relies on the array keys being defined in the exact same order as the items in the list()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we control both, so why wouldn't they?
Co-authored-by: Weston Ruter <westonruter@google.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
Merging for importing into |
Summary
This PR adds a new
PreloadHeroImage
transformer.This transformer optimizes image rendering times for hero images by adding preload and serverside-rendered
<img>
tags when possible. Viable hero images are<amp-img>
tags,<amp-video>
tags with aposter
attribute as well as<amp-iframe>
and<amp-video-iframe>
tags with aplaceholder
attribute. The first viable image that is encountered is used by default, but this behavior can be overridden by adding thedata-hero
attribute to a maximum of two images. The preloads only work work images that don't usesrcset
, as that is not supported as a preload in most browsers. The serverside-rendered image will not be created for<amp-video>
tags.Fixes #5055
Checklist