Validator: allow additional amp-keyframes style
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:
- The
amp-keyframesstyle will only be allowed to contain@keyframesand@media/@supportswith@keyframesrules and their vendor-prefixed versions. - The maximum allowed size for this style tag is 200K
- 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>
Will this be allowed for Amp Ads documents?
Yes. Primary use case, in fact.
Also this: https://github.com/ampproject/amphtml/issues/11430
This validator change is now live everywhere.