1

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.

Dan F
  • 11,958
  • 3
  • 48
  • 72
Ronedog
  • 2,313
  • 8
  • 43
  • 85

2 Answers2

6

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

Community
  • 1
  • 1
Dan F
  • 11,958
  • 3
  • 48
  • 72
2

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
  • 242,243
  • 40
  • 408
  • 536