I am having issues with lag when using a combination of two CSS animations. The first one animates text shadow on a text, and the second animation is animating two SVG's in the background. On Firefox it doesn't lag very much, but on Chrome it's really bad. Here is a video of it.
Here is a snippet:
/*NEON TEXT CODE*/
#flicker {
animation: flicker-text 1.5s infinite alternate;
font-size: 36px;
color: white;
}
@keyframes flicker-text {
0%,
18%,
22%,
25%,
53%,
57%,
100% {
text-shadow: 0 0 4px #fff, 0 0 11px #fff, 0 0 19px #fff, 0 0 40px #B0D9DD, 0 0 80px #B0D9DD, 0 0 90px #B0D9DD, 0 0 100px #B0D9DD, 0 0 150px #B0D9DD;
}
20%,
24%,
55% {
text-shadow: none;
}
}
/*OCEAN AND WAVE CODE*/
#ocean-container-vs-code {
position: fixed;
top: 0;
left: 0;
z-index: -9999;
height: 100%;
width: 100%;
}
.ocean {
height: 5%;
width: 100%;
position: absolute;
bottom: 0;
left: 0;
background: #015871;
}
.wave {
background: url(//dd7tel2830j4w.cloudfront.net/f1659025056348x434203136138475760/wave.svg) repeat-x;
position: absolute;
top: -198px;
width: 6400px;
height: 198px;
-webkit-animation: wave 7s cubic-bezier(0.36, 0.45, 0.63, 0.53) infinite;
animation: wave 7s cubic-bezier(0.36, 0.45, 0.63, 0.53) infinite;
transform: translate3d(0, 0, 0);
}
.wave:nth-of-type(2) {
top: -175px;
-webkit-animation: wave 7s cubic-bezier(0.36, 0.45, 0.63, 0.53) -0.125s infinite, swell 7s ease -1.25s infinite;
animation: wave 7s cubic-bezier(0.36, 0.45, 0.63, 0.53) -0.125s infinite, swell 7s ease -1.25s infinite;
opacity: 1;
}
@-webkit-keyframes wave {
0% {
margin-left: 0;
}
100% {
margin-left: -1600px;
}
}
@keyframes wave {
0% {
margin-left: 0;
}
100% {
margin-left: -1600px;
}
}
@-webkit-keyframes swell {
0%,
100% {
transform: translate3d(0, -25px, 0);
}
50% {
transform: translate3d(0, 5px, 0);
}
}
@keyframes swell {
0%,
100% {
transform: translate3d(0, -25px, 0);
}
50% {
transform: translate3d(0, 5px, 0);
}
}
<div id="ocean-container-vs-code" style="background:linear-gradient(90deg, #faf0cd, #fab397)">
<div class="ocean">
<div class="wave"></div>
<div class="wave"></div>
</div>
</div>
<p id="flicker">This is some test text</p>
Does anyone have any insight on why combining these two animations causes severe lag? What am I doing wrong here?
Thanks so much!
EDIT: Pay attention to when the text flickers. On the moment the text flickers, the waves lag.