Currently, when the user clicks on a button, several javascript functions get executed. Because every function does some animation (more information on this can be found in the second comment) on the site, I have to execute them one after another so jQuery will not mess up because it started an animation on an element that isn't even loaded / displayed yet.
My current solution is to call every function a bit later then the previous one by using setTimeout
like this:
window.setTimeout(functionA,250);
window.setTimeout(functionB,500);
This works great in Chrome, but in Firefox things are still executed too fast sometimes. So I'm looking to fix this workaround by telling Javascript to only execute the next function when the previous one has completely finished.
I've already read about adding a callback - but I got a lot of functions to call. Do I really have to add a callback to every single function to achieve what I want?
Many thanks in advance.