Updated with code suggestions - try/catch & a define for the apps server CDN URL