I am using the text plug in on a page and have poor site speed performance as a result. It also jerks on some devices. When I deactivate the text effect, I have 99% in the Lighthouse Speed Test, and 29% when it is activated.
Is there a better way to avoid such an effect?
Here is the code for the effect:
gsap.registerPlugin(ScrollTrigger, SplitText);
console.clear();
select = e => document.querySelector(e);
selectAll = e => document.querySelectorAll(e);
const captions = selectAll(".text-container");
captions.forEach((caption, i) => {
var splitTextTitle = new SplitText(caption.querySelector(".text-fx"), {type:"chars, words"}),
lettersTitle = splitTextTitle.chars;
let tl = gsap.timeline({
scrollTrigger: {
trigger: caption,
toggleActions: "play reset play reset",
}
});
tl.from(lettersTitle, {
opacity:0, yPercent:-100, ease:"power2", duration: 0.2, stagger: { each: 0.005, }
});
});
If someone has a suggestion, I would be very happy.
Thanks a lot