I have a progress bar, I need to make it an animated background, here’s an example:
.progress-bar { position: relative; overflow: hidden; height: 8px; border-radius: 5px; margin: 8px 0; background: linear-gradient(to right, #4A90E2 0%, #9BFAC0 50%, #4A90E2 100%); background-size: 200% 100%; animation: progress 3s ease infinite; border: 1px solid #CCC; } @keyframes progress { 0% { background-position: 200% 0% } 99% { background-position: 0% 0% } 100% { background-position: 0% 0% } } <div class="progress-bar"></div> With this animation, the load on cpu in the region of 10-30% of the macbookpro without a separate gpu.
Maybe someone came across this and how is it possible to implement such an animation without such a load?
Of course, I thought that background-position animation is not the best option, but absolutely the same behavior even with inserting png pictures with animation on translateX (and indicating will-change: transform)
I experiment further, the problem is made even without a gradient, with the most lightweight code and simple linear animation:
.progress-bar { position: relative; overflow: hidden; height: 8px; border-radius: 5px; margin: 8px 0; background: #4A90E2; border: 1px solid #CCC; } .progress-bar:before { content: ''; display: block; background: #9BFAC0; width: 50%; height: inherit; animation: progress 3s linear infinite; will-change: transform; } @keyframes progress { from { transform: translateX(-200%) } to { transform: translateX(200%) } } <div class="progress-bar"></div> UPD I tried almost all the options and did not find a solution. You can reduce the load by changing the animation by doing it at intervals. A similar load is shown on toggle class + transition. SVG animation - 1.5 times the load. Everything that is in Google that will-change and null transform does not help. Does gif remain? But he, too, will be redrawn, but he can set the frame rate.