<svgid="js-ani"width="120"height="80"xmlns="http://www.w3.org/2000/svg"> <circleid="js-circle"cx="20"cy="40"r="15"fill="#E57373" /> <script><![CDATA[ let c = document.getElementById('js-circle'); let dir = 1, x = 20; function animate() { x += dir * 2; if (x > 100 || x < 20) dir *= -1; c.setAttribute('cx', x); requestAnimationFrame(animate); } animate(); ]]></script> </svg>