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

Add allow-important for style[amp-runtime] on a transformed document #37761

Open
schlessera opened this issue Feb 23, 2022 · 5 comments
Open

Comments

@schlessera
Copy link
Contributor

Description

The issue we're currently seeing with the PHP AMP Toolbox (ampproject/amp-toolbox-php#496) is that the SSR-produced version of the page includes !important tags in the <style amp-runtime> element, as they are coming from the amp-runtime.css and from extensions like amp-ad.

This currently would mean that SSR is not a viable option, as it includes inlining the CSS that makes up the AMP runtime and the extensions. If that cannot be done, the whole approach of SSR is without value.

So, in that regard, the !important tag would need to be supported within the <style amp-runtime> element on a transformed document as well. If not, any try at doing SSR will lead to validation errors in the Google Search Console.

Alternatives Considered

We couldn't come up with a viable alternative so far. Here's what we considered:

  • removal of the !important tags before inlining would break the layout
  • not inlining breaks/invalidates SSR

Additional Context

SSR applies the transformations that the AMP Cache would do, but does them on the origin server. As such, SSR moves these transformations from _after the validation to _before the validation. Therefore, validation needs to be able to take SSR transformations into account. This includes applying whatever CSS AMP would apply via the runtime without SSR, and that includes the !important tag.

@erwinmombay
Copy link
Member

this seems like a reasonable ask to keep on having the viability of SSR'ing on Origin. @schlessera how does an extension like amp-ad play into this btw? does that trigger additional css to be inserted into style[amp-runtime] ?

cc @jridgewell for visibility

@jridgewell
Copy link
Contributor

SGTM

@schlessera
Copy link
Contributor Author

@erwinmombay Yes, an extension like amp-ad comes with its own CSS to be included. In the particular case of amp-ad, this also includes the !important modifier (see https://github.com/ampproject/amphtml/blob/main/extensions/amp-ad/0.1/amp-ad.css).

@erwinmombay
Copy link
Member

@schlessera gotcha. i just want to make sure that it is not inserted into its own <style amp-extension="amp-ad"> element or if its in <style amp-runtime>

@stale
Copy link

stale bot commented Sep 17, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

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

No branches or pull requests

6 participants