Execute parts of code by sequence that we want

I write my code in: (site and page place),
When i publish (preview) my Wix website, page code is starting to run then site code is running, while i want to be done it as reverse.
Further more i need to adjusting code to run by sequence of we want.
(As i know the code not run line by line and these lines run as parallel).
for example i want to do:

Is there any function or procedure to solve this problem without changing lines of functions (or our desired part of code)?

thanks all :slight_smile:

Hi,
You can use Promises in order to make sure that one function runs before the other. I recommend reading the MDN documentation here and the Async Await explanation here .

Good luck :slight_smile:
Tal.