SlexAxton/yepnope.js — Issue #92: Question about preloading vs execution
Author: thegrandpoobah
Created: 2012-02-17 19:22:56+00:00
State: open

Not entirely certain if this is the right forum for this, but I couldn't find anything better.

I have a question about an assumption that I am making in my code w.r.t. to script loading with yepnope that I hope you guys can either confirm or debunk. Bascailly, it boils down to me repeating the following yepnope code block, but for different scripts:

yepnope({load: 'some_url', complete: function() { console.log(window.globaltokens); window.globaltokens = {}; }});

The scripts that I load, perform one function that is relevent to this question:

window.globaltokens[make_guid()] = 'some value';

where make_guid is a guid generator function.

Now, my assumption is that window.globaltokens only ever has one key inside of it in the **complete** callback of the yepnope calls. That is, because browsers guarantee callback execution immediately after load, and because yepnope guarantees execution order (but not loading order), AND because everything gets executed in one execution thread, there is no way for the glboaltokens map to have more than one entry at a time. Now, I read the note at the bottom of the yepnope page regarding IE<9 not having immediate callback order (which doesn't matter to me, since I'm only targetting IE9+, FF, and Chrome) AND @jaubourg's blog post on the topic that you've posted, and I *think* my assumption is correct, but I'd like to hear from the people who have waaaay more experience with this script loading stuff to get a good handle on if I'm just getting lucky that things are working right now?

Thanks in advance and thanks for a great simple tool :)