-
Notifications
You must be signed in to change notification settings - Fork 243
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 experimental amp-img -> img transformation #859
Conversation
@@ -110,8 +110,7 @@ function maybeAddSizerInto(node, layout, width, height) { | |||
sizer = createIntrinsicSizer(width, height); | |||
} | |||
if (sizer) { | |||
const referenceNode = node.firstChild; | |||
insertBefore(node, sizer, referenceNode); | |||
appendChild(node, sizer); |
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.
Looks like the sizer needs to be added after the img.
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.
Sizer always goest first for responsive
. Is there a bug you're seeing when sizer is first?
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.
Hm. Not sure what I tested there. All good with sizer first.
@@ -110,8 +110,7 @@ function maybeAddSizerInto(node, layout, width, height) { | |||
sizer = createIntrinsicSizer(width, height); | |||
} | |||
if (sizer) { | |||
const referenceNode = node.firstChild; | |||
insertBefore(node, sizer, referenceNode); | |||
appendChild(node, sizer); |
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.
Sizer always goest first for responsive
. Is there a bug you're seeing when sizer is first?
return; | ||
} | ||
const imgNode = createElement('img', { | ||
class: 'class=i-amphtml-fill-content i-amphtml-replaced-content', |
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.
class: 'class=i-amphtml-fill-content i-amphtml-replaced-content', | |
class: 'i-amphtml-fill-content i-amphtml-replaced-content', |
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.
fixed
generateImg(node) { | ||
if (!this.experimentImg) { | ||
return; | ||
} |
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.
I think we were only going to do this transform for amp-img
s that have a data-hero
attr set. Since we can't guarantee loading=lazy
behavior for most browsers yet, we don't want to load a bunch of far-from-viewport images.
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.
Introduce a max upper bound of 2 hero images and switched to loading=eager
for these.
This commit introduces the data-hero attribute as a means to explicitly markup hero amp-img or amp-iframe elemenents. Other changes: * don't bail out if there are any kind of image preloads, instead check the img src to avoid duplicates * use loading=eager instead of loading=lazy
Adressed the comments, also:
PTAL |
const imgNode = createElement('img', { | ||
class: 'i-amphtml-fill-content i-amphtml-replaced-content', | ||
decoding: 'async', | ||
loading: 'eager', |
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.
I think we can drop this attr.
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.
done
@jridgewell Thanks for the review! |
This commit introduces the data-hero attribute as a means to explicitly markup hero amp-img or amp-iframe elemenents. Other changes: * don't bail out if there are any kind of image preloads, instead check the img src to avoid duplicates * don't use loading=lazy * print warning if there are too many hero elements on a page
Introduce data-hero attribute which will disable auto hero detection.