tags:

views:

43

answers:

3

If I have an event that runs multiple javascripts does the following script wait until the previous script is complete before it runs?

Example:

<a href="#" onclick="javascript:SCRIPT_1();SCRIPT_2();SCRIPT_3();">Test Me</a>

Will SCRIPT_2 not execute until SCRIPT_1 is complete doing its stuff?

Thanks.

+6  A: 

AFAIK, yes, javascript execution is synchronous. So, SCRIPT_2 will not execute untill SCRIPT_1 is done.

edit Yep, the accepted answer on when-is-javascript-synchronous is worth a read

Dan F
Yes, Javascript is single-threaded.
jsight
Thanks AFAIK...and thanks for that read.
Ronedog
+2  A: 

That is correct. Javascript is executed synchronously so SCRIPT_1 will complete before SCRIPT_2 begins (at least when defined like you have).

Justin Niessner
A: 

Answered perfectly, thanks guys.

Ronedog