I recognise this question probably goes to how Javascript functions operate in general (and not just my particular case), but…
I want to know how my document ready function… umm… functions. In stylised form, it’s like the following:
$(function () {
object1.init();
object2.init();
object3.init(); etc...
Will object2.init() only fire when object1.init() returns? Or will they all fire in an asynchronous kind of way?
UPDATE: If they fire sequentially, is there any way I can get them to go simultaneously (which I possibly don’t need to do)?
Thanks.
object2.init() only fire when object1.init() returns.
All the functions are stored in a queue, and get fired one after the other.
There is no way to make them fire simultaneously.
Not just jQuery, but javascript doesn’t support parallel programming.
You can see the jQuery source code:
( Update: I removed the actuall code, because the answer became a mini jQuery source code…)
Check those functions and variables in the jQuery source code