It sounds like in the first load the eventListener is not getting registered before the loadModule() method.
Subsequent calls work because of the event listener added from the first attempt. I suggest you move moduleLoader.id = moduleName; moduleLoader.url = moduleName; to the very end. Thanks, Gaurav

