Jump to content
Search Community

GSAP freezes when javascript executes long running tasks

bb_nic test
Moderator Tag

Recommended Posts

Hello, I'm a very new user of gsap.

I'm trying to make an animation on my website's loading screen,  in order to cover up the heavy and long running calculations I need to do before showing the page.

But for a couple of seconds the gsap animation just freezes.

 

My js cannot be split up in small chunks of code and I cannot put it in a web worker, so:

Is there a way to run the gsap animation nice and smooth while doing heavy cpu bound calculations?

 

Thank you  very much!

Link to comment
Share on other sites

Hey @bb_nic

mmm. Tricky. Doing more JS to try and cover up lag from a bunch of JS calculations sounds like a less than ideal approach.

This is why animated loading gifs were used back in the day 😬 I would personally try to either offload or delay some of the initial calculations or animate with CSS in this case.
 

Link to comment
Share on other sites

4 hours ago, Cassie said:

I would personally try to either offload or delay some of the initial calculations or animate with CSS in this case.

Just beware that even if you use CSS instead, that won't help unless you ONLY animate transforms and/or opacity. Any other properties are bound to the main thread updates, so if you're locking the main thread due to your very heavy JS calculations, it won't be able to repaint the screen with animation updates. 

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...