Add code to check for require.on before calling it to allow dojox/app to work with other loaders. fixes #18171

(cherry picked from commit 3f58ca49510561cdb1a27dc8af37ce694083244f)