diff --git a/lib/style-ast.js b/lib/style-ast.js index d8fc3b8..bb3f401 100644 --- a/lib/style-ast.js +++ b/lib/style-ast.js @@ -6,6 +6,7 @@ const stringPattern = /^(["']).*\1$/; const maxBase64Length = 1000; const excludedSelectors = [ /::?(?:-moz-)?selection/ ]; const excludedProperties = [ + /(.*)animation/, /(.*)transition(.*)/, /cursor/, /pointer-events/, @@ -70,6 +71,7 @@ class StyleAST { ); clone.pruneMediaQueries(); + clone.pruneKeyframes(); clone.pruneNonCriticalSelectors( criticalSelectors ); clone.pruneExcludedProperties(); clone.pruneLargeBase64Embeds(); @@ -265,6 +267,21 @@ class StyleAST { } ); } + /** + * Remove keyframe definitions. + */ + pruneKeyframes() { + csstree.walk( this.ast, { + visit: 'Atrule', + enter: ( atrule, atitem, atlist ) => { + // Ignore non-keyframes. + if ( csstree.keyword( atrule.name ).basename === 'keyframes' ) { + atlist.remove( atitem ); + } + }, + } ); + } + /** * Returns true if the given CSS rule object relates to animation keyframes. *