This is a situation that clobbered me for hours: I had
RegisterSod('jquery.js','/_layouts/15/jquery/jquery211.js');
SP.SOD.executeFunc('jquery.js',null,function() { alert('hello');})
in a script block my master page and a duplicate script block in a Control_blah.js display template:
AddPostRenderCallback(ctx, function () {
if (LoadSodByKey('jquery.js', null) == Sods.missing) {
RegisterSod('jquery.js', '/_layouts/15/jquery/jquery211.js');
}
SP.SOD.executeFunc('jquery.js', null, function () { alert('in template')});
})
(As you can see, there was a little more to it because I use LoadSodByKey to test before registering and I use that in the master page, too.)
The problem is that only the function in the master page will fire this way. The only way I could get both to fire was to use a different SOD key in the display template. There, I used 'jqueryX.js'. This seems ridiculous but after 5 hours of messing with it and trying all sorts of things (including Mountain Dew mixed with Jolt!) I was open to doing anything.
I'm sure I am missing something obvious but I watched ULS and did not see any bad requests come in. It appears as though the use of the same key kills
the callback so that once jquery211.js is loaded, only one of the awaiting functions gets fired. This is terrible because it means I would need to put different key for jquery throughout my farm. That isn't feasible so I know I am doing something wrong.