IFF your dialog stuff is all actually JavaScript, then doing a late-loading is fairly easy.
function runNpcDialog(number) { require("npc["npc-dialog-" + number + ".js"js"], function(dialog) { // Run your dialog here. }); } Otherwise, if your information is more of a JSON/XML format, then using ajax would be a better option.
EDIT: Fixed syntax