I'm starting up a web application that have multiple procedure which takes some time. To reduce loading time, I want to implement async processing like following:
loadXML()-----
\
loadCanvas()---setupCanvas()
\
setupYoutubePlayer()---------startApplication()
That is, when page is loaded, I want to start loadXML(), loadCanvas() and
setupYoutubePlayer() simultaneously, and fire setupCanvas() when loadXML() and
loadCanvas() is done, and setupApplication() to fire after setupCanvas() and
setupYoutubePlayer() is done.
loadXML() and setupCanvas() contains AJAX processing, and setupYoutubePlayer() contains API access and is required API-specified callback function (onYouTubeIframeAPIReady()).
After some days of googling, I found
jQuery.Deffered and
Async.js. Speaking about Deffered, I could wrap all
processes by Deferred.promise() and Deferred.resolve(), but I found no easy solution
to implement this nested async processing using when() and then().
And as for Async.js, I have no idea to deal with setupYoutubePlayer().
I missed something? Or are there another knowledge in this case? Please help. Thanks.