(function() { // globals MyApp.Shell = {}; // utility functions // app functions MyApp.Shell.renderShell = function() { document.title = i18next.t('vanillaJS'); var d = $.Deferred(); //preload this template, so we can be sure the dom in rendered when we resolve ejs.preloadTemplate('/app/shell/templates/main.ejs') .then(function(templateUrl) { $('.js-main-content').html(ejs.rr(templateUrl)); d.resolve(); }); return d; }; MyApp.Shell.renderHomePage = function() { $('.js-page-container').html(ejs.rr('/app/shell/templates/home.ejs')); }; // events // app startup page('/', MyApp.Shell.renderHomePage); })();