gsap.registerPlugin(TextPlugin); const initial='This is the original text';const target=document.querySelector('h1'); function replaceText(){gsap.killTweensOf(target);target.textContent=initial;// replaces h1's text with "This is the new text" over the course of 2 seconds gsap.to("h1", { duration: 2, text: "This is the new text", ease: "none", }); } document.getElementById('replace').addEventListener('click',replaceText);