Hi,
I have run into some issues using the SOD executeFunc() method when it is run more than once on a page for the same script key. The issue seems to be that if a script loads fast enough, before a subsequent executeFunc() statement is called, the callback on that 2nd executeFunc call will not be fired. Seems to be because it's the notify does not get called if a script is already loaded. And if the script loads before your 2nd executeFunc() call is processed you miss out on the notifyScriptLoadedAndExecuteWaitingJobs() call in the loaded script itself. You can reproduce the issue simply by using your console to run your executeFunc() call after the page has completely loaded. If the script was already loaded by another call your console call will not fire its callback.
So I poked around the JS a bit and found SP.SOD.loadMultiple(). This seems to work a lot better as it does a couple of things:
1. It lets me load multiple scripts in one statement vs a bunch of nested executeFunc() calls. To load just a single script you can pass in a one item array.
2. If I call it with a script key or multiple script keys after those scripts have been loaded it will still cycle through, verify all scripts are loaded, and make sure to fire off my callback.
Wondering if this is a bug with executeFunc()? I would think that calling it at any point would ensure to fire off my callback (especially if the script is already loaded).
Thanks