开发者

Finding out what Javascript will run and when

开发者 https://www.devze.com 2023-04-09 23:05 出处:网络
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 al

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消