amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Validator: allow additional amp-keyframes style

Open dvoytenko opened this issue 9 years ago • 4 comments

The goal is to allow a bigger <style> aimed for animations. Animations are often bigger in size due to heavy use of vendor prefixes and due to high detail in mutations. On the plus side, however, keyframes animations do not affect the critical rendering path.

The format will be:

<style amp-keyframes>
</style>

The following rules will be applied to this tag:

  1. The amp-keyframes style will only be allowed to contain @keyframes and @media/@supports with @keyframes rules and their vendor-prefixed versions.
  2. The maximum allowed size for this style tag is 200K
  3. Must be at the bottom of the document. In other words, it should come after all content elements.

Thus, a valid markup could look something like this:

<style amp-keyframes>
@keyframes anim1 {
  0% {transform: translateX(-100%);}
  100% {transform: translateX(100%);}
}
@-webkit-keyframes anim1 {
  0% {transform: translateX(-100%);}
  100% {transform: translateX(100%);}
}
@media (min-width: 300px) {
  @keyframes anim1 {
    0% {transform: translateX(-200%);}
    100% {transform: translateX(200%);}
  }
}
@supports (offset-distance: 0) {
  @keyframes anim1 {
    0% {offset-distance: 0}
    100% {offset-distance: 100%}
  }
}
</style>

dvoytenko avatar May 30 '17 23:05 dvoytenko

Will this be allowed for Amp Ads documents?

Gregable avatar Aug 15 '17 17:08 Gregable

Yes. Primary use case, in fact.

dvoytenko avatar Aug 15 '17 19:08 dvoytenko

Also this: https://github.com/ampproject/amphtml/issues/11430

chenshay avatar Sep 25 '17 23:09 chenshay

This validator change is now live everywhere.

Gregable avatar Nov 15 '17 18:11 Gregable