How can I keep track of what scripts have been loaded so far so I can display a progress bar when using labjs (http://labjs.com/)? wait()
doesn't work because then it won't parallel load the next resource. Basically i'm looking for some kind of non-blocking callback function i can tie into. Does this exists in labjs?
displaying progress bar for labjs, labjs callbacks
248 views Asked by LordZardeck At
1
wait()
does not affect the parallel loading of LABjs... it will always parallel load as much as possible (allowed by the browser).wait()
only affects the execution of scripts. If it's inserted between twoscript()
calls, it ensures that the second script will "wait" for the first script to finish executing before it executes.No, there is no exposed API for the load-finishing on scripts, because browsers do not expose a consistent API for when a script finishes loading (only when it executes: "onload", as confusing as that name is).
Now, you can do a progress meter using
wait()
calls in between each script, but it will tell you something slightly different than what you asked: what percentage of the scripts have executed, not what percentage of the scripts have downloaded. Depending on your needs, that might be quite acceptable.