amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

✨Allow img tag within amp documents template✨

Open JakeSquier opened this issue 2 years ago • 6 comments

With this minuscule change to the codebase, I am allowing img to be used within amp-mustache; This will enable a slew of possibilities. More specifically allowing the option to improve LCP scores via native img support, which cannot be done with the current restrictions on the img tag.

JakeSquier avatar Feb 28 '23 08:02 JakeSquier

this would essentially be allowing the usage of the img element in an amp documents i think. (though it will bypass validation)

@alanorozco could i get your opinion on this?

erwinmombay avatar Mar 07 '23 19:03 erwinmombay

this would essentially be allowing the usage of the img element in an amp documents i think. (though it will bypass validation)

@erwinmombay yes, that is the idea. I understand this will be a controversial change, but this would allow developers to opt-in or out of amp-img usage. Unfortunately, there are development strategies that could increase LCP scores but cannot be implemented with the required use of amp-img. I am eager to hear @alanorozco thoughts on the idea. With positive feedback and an agreed-upon strategy for rewriting tests, I will begin updating the tests.

JakeSquier avatar Mar 08 '23 03:03 JakeSquier

How does this impact AMP formats other than AMP websites, where validation is used for more than performance (e.g. stories rely on validation for UI/UX; email and ads rely on validation for security)?

newmuis avatar Mar 08 '23 04:03 newmuis

i think we also need to double check that the img fetch does not occur during prerendering scenarios for privacy reasons

erwinmombay avatar Mar 09 '23 18:03 erwinmombay

@erwinmombay I apologize for being inactive on this PR have been rather busy. This has become of higher priority so will be pushing on this frequently to get this in as soon as possible. I will reply on this thread today in regards to @newmuis comment!

JakeSquier avatar Mar 21 '23 06:03 JakeSquier

How does this impact AMP formats other than AMP websites, where validation is used for more than performance (e.g. stories rely on validation for UI/UX; email and ads rely on validation for security)?

I don't think it would make much sense to whitelist img within other AMP formats; As the addition would not bring much utility within stories nor email, and would also result into a lot of unnecessary changes. I think it is best for the whitelisting of img tag to be exclusive to AMP websites. We could utilize a function to identify the current format while validating, if is AMP websites format the validation process will allow img within the document. This would be a fairly similar approach to the use of isAmp4Email(doc) in order to evaluate (isEmail ? EMAIL_DENYLISTED_TAG_SPECIFIC_ATTRS : {}) if the addition of EMAIL_DENYLISTED_TAG_SPECIFIC_ATTRS is needed within the sanitation process. I see this being a realistic approach and would avoid interrupting other formats. I will begin implementation and update this PR with those changes. I would like to see if this an accepted approach by you all! @erwinmombay @newmuis

JakeSquier avatar Mar 21 '23 07:03 JakeSquier