Finding out what Javascript will run and when
What's the best way of finding out what Javascript will run and when? I've out开发者_运维技巧grown placing functions inside setTimeouts to delay running code to when I think the dependencies have already loaded, etc.
Assuming you're not interested in putting the code that needs those calls in the onload
event handler (will be invoked when all resources have been loaded), probably because you've got too many resources to load, or have some user behavior dependant on those resources, which might be triggered before it is loaded.
You might be interested in this resource: Dynamic resource management in JavaScript. There's an script through which you can load resources, and specify function callbacks to be invoked when the resource is loaded.
Would jQuery's document ready method solve your problems?
精彩评论